:: [a] -> a -> [a]

Replace the last element of a list with another element.
Append an element to the end of a list, takes O(n) time.
snoc "tes" 't' == "test"
\xs x -> unsnoc (snoc xs x) == Just (xs,x)
Append a single element at the end. Time: O(length); use only on small lists.
Specialisation of $>.
O(n) Append an element
Flipped version of <$.

Examples

Replace the contents of a Maybe Int with a constant String:
>>> Nothing $> "foo"
Nothing
>>> Just 90210 $> "foo"
Just "foo"
Replace the contents of an Either Int Int with a constant String, resulting in an Either Int String:
>>> Left 8675309 $> "foo"
Left 8675309
>>> Right 8675309 $> "foo"
Right "foo"
Replace each element of a list with a constant String:
>>> [1,2,3] $> "foo"
["foo","foo","foo"]
Replace the second element of a pair with a constant String:
>>> (1,2) $> "foo"
(1,"foo")
Flipped version of <$.

Examples

Replace the contents of a Maybe Int with a constant String:
>>> Nothing $> "foo"
Nothing

>>> Just 90210 $> "foo"
Just "foo"
Replace the contents of an Either Int Int with a constant String, resulting in an Either Int String:
>>> Left 8675309 $> "foo"
Left 8675309

>>> Right 8675309 $> "foo"
Right "foo"
Replace each element of a list with a constant String:
>>> [1,2,3] $> "foo"
["foo","foo","foo"]
Replace the second element of a pair with a constant String:
>>> (1,2) $> "foo"
(1,"foo")
Flipped version of <$. @since base-4.7.0.0

Examples

Replace the contents of a Maybe Int with a constant String:
>>> Nothing $> "foo"
Nothing
>>> Just 90210 $> "foo"
Just "foo"
Replace the contents of an Either Int Int with a constant String, resulting in an Either Int String:
>>> Left 8675309 $> "foo"
Left 8675309
>>> Right 8675309 $> "foo"
Right "foo"
Replace each element of a list with a constant String:
>>> [1,2,3] $> "foo"
["foo","foo","foo"]
Replace the second element of a pair with a constant String:
>>> (1,2) $> "foo"
(1,"foo")
Flipped version of <$. Using ApplicativeDo: 'as $> b' can be understood as the do expression
do as
pure b
with an inferred Functor constraint.

Examples

Replace the contents of a Maybe Int with a constant String:
>>> Nothing $> "foo"
Nothing

>>> Just 90210 $> "foo"
Just "foo"
Replace the contents of an Either Int Int with a constant String, resulting in an Either Int String:
>>> Left 8675309 $> "foo"
Left 8675309

>>> Right 8675309 $> "foo"
Right "foo"
Replace each element of a list with a constant String:
>>> [1,2,3] $> "foo"
["foo","foo","foo"]
Replace the second element of a pair with a constant String:
>>> (1,2) $> "foo"
(1,"foo")
the same as ($>)
decomposeVarPositional [b0,b1,b2,...] x decomposes x into a positional representation with mixed bases x0 + b0*(x1 + b1*(x2 + b2*x3)) E.g. decomposeVarPositional (repeat 10) 123 == [3,2,1]
Polynomial integration
Compute the right scalar product
>>> V2 3 4 ^* 2
V2 6 8
Compute division by a scalar on the right.
Raise a polynomial to a non-negative integer power
The intersperse function takes an element and a list and `intersperses' that element between the elements of the list.

Laziness

intersperse has the following properties
>>> take 1 (intersperse undefined ('a' : undefined))
"a"
>>> take 2 (intersperse ',' ('a' : undefined))
"a*** Exception: Prelude.undefined

Examples

>>> intersperse ',' "abcde"
"a,b,c,d,e"
>>> intersperse 1 [3, 4, 5]
[3,1,4,1,5]
Append an element to the start of a list, an alias for (:).
cons 't' "est" == "test"
\x xs -> uncons (cons x xs) == Just (x,xs)
The intersperse function takes an element and a list and `intersperses' that element between the elements of the list. For example,
>>> intersperse ',' "abcde"
"a,b,c,d,e"
intersperse has the following laziness properties:
>>> take 1 (intersperse undefined ('a' : undefined))
"a"

>>> take 2 (intersperse ',' ('a' : undefined))
"a*** Exception: Prelude.undefined