intersperse

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]
'intersperse x xs' alternates elements of the list with copies of x.
intersperse 0 (1 :| [2,3]) == 1 :| [0,2,0,3]
O(n) The intersperse function takes a Word8 and a ByteString and `intersperses' that byte between the elements of the ByteString. It is analogous to the intersperse function on Lists.
O(n) The intersperse function takes a Char and a ByteString and `intersperses' that Char between the elements of the ByteString. It is analogous to the intersperse function on Lists.
The intersperse function takes a Word8 and a ByteString and `intersperses' that byte between the elements of the ByteString. It is analogous to the intersperse function on Lists.
O(n) The intersperse function takes a character and places it between the characters of a Text. Example:
>>> T.intersperse '.' "SHIELD"
"S.H.I.E.L.D"
Performs replacement on invalid scalar values.
O(n) Take a character and place it between each of the characters of a 'Stream Char'. Properties
unstream . intersperse c . stream = intersperse c
O(n) The intersperse function takes a character and places it between the characters of a Text. Performs replacement on invalid scalar values.
Intersperse an element between the elements of a sequence.
intersperse a empty = empty
intersperse a (singleton x) = singleton x
intersperse a (fromList [x,y]) = fromList [x,a,y]
intersperse a (fromList [x,y,z]) = fromList [x,a,y,a,z]
Insert the given value between each two values in the stream. Subject to fusion
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
The function intersperse v s wraps the OutputStream s, creating a new output stream that writes its input to s interspersed with the provided value v. See intersperse. Example:
ghci> import Control.Monad ((>=>))
ghci> is <- Streams.fromList ["nom", "nom", "nom"::ByteString]
ghci> Streams.outputToList (Streams.intersperse "burp!" >=> Streams.connect is)
["nom","burp!","nom","burp!","nom"]
Intersperse given value between each element of the stream.
>>> S.print $ S.intersperse 0 $ each [1,2,3]
1
0
2
0
3
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"
O(n) The intersperse function takes a character and places it between the characters of a Text. Example:
>>> T.intersperse '.' "SHIELD"
"S.H.I.E.L.D"
Subject to fusion. Performs replacement on invalid scalar values.
O(n) The intersperse function takes a character and places it between the characters of a Text. Subject to fusion. Performs replacement on invalid scalar values.
intersperse takes an element and intersperses that element between the elements of the sequence.
> intersperse ',' "abcde"
"a,b,c,d,e"
Insert character between characters of ShortText.
>>> intersperse '*' "_"
"_"
>>> intersperse '*' "MASH"
"M*A*S*H"
Intersperse a Word8 in between the bytes of the byte stream
The intersperse function takes a Word8 and a ByteStream and `intersperses' that byte between the elements of the ByteStream. It is analogous to the intersperse function on Streams.
The intersperse function takes a Char and a ByteStream and `intersperses' that byte between the elements of the ByteStream. It is analogous to the intersperse function on Streams.
Add an item between each element in the structure
O(n) The intersperse function takes a character and places it between the characters of a JSString. Subject to fusion. Performs replacement on invalid scalar values.
Insert a pure value between successive elements of a stream.
>>> Stream.toList $ Stream.intersperse ',' $ Stream.fromList "hello"
"h,e,l,l,o"
Intersperses the given character between the YiStrings. This is useful when you have a bunch of strings you just want to separate something with, comma or a dash. Note that it only inserts the character between the elements. What's more, the result is a single YiString. You can easily achieve a version that blindly inserts elements to the back by mapping over the list instead of using this function. You can think of it as a specialised version of intercalate. Note that what this does not do is intersperse characters into the underlying text, you should convert and use intersperse for that instead.