intercalate

intercalate xs xss is equivalent to (concat (intersperse xs xss)). It inserts the list xs in between the lists in xss and concatenates the result.

Laziness

intercalate has the following properties:
>>> take 5 (intercalate undefined ("Lorem" : undefined))
"Lorem"
>>> take 6 (intercalate ", " ("Lorem" : undefined))
"Lorem*** Exception: Prelude.undefined

Examples

>>> intercalate ", " ["Lorem", "ipsum", "dolor"]
"Lorem, ipsum, dolor"
>>> intercalate [0, 1] [[2, 3], [4, 5, 6], []]
[2,3,0,1,4,5,6,0,1]
>>> intercalate [1, 2, 3] [[], []]
[1,2,3]
O(n) The intercalate function takes a ByteString and a list of ByteStrings and concatenates the list after interspersing the first argument between each element of the list.
O(n) The intercalate function takes a ShortByteString and a list of ShortByteStrings and concatenates the list after interspersing the first argument between each element of the list.
O(n) The intercalate function takes a Text and a list of Texts and concatenates the list after interspersing the first argument between each element of the list. Example:
>>> T.intercalate "NI!" ["We", "seek", "the", "Holy", "Grail"]
"WeNI!seekNI!theNI!HolyNI!Grail"
intercalate str strs inserts the stream str in between the streams strs and concatenates the result. Properties
intercalate s = concat . intersperse s
O(n) The intercalate function takes a Text and a list of Texts and concatenates the list after interspersing the first argument between each element of the list.
intercalate xs xss is equivalent to (concat (intersperse xs xss)). It inserts the list xs in between the lists in xss and concatenates the result.
>>> intercalate ", " ["Lorem", "ipsum", "dolor"]
"Lorem, ipsum, dolor"
intercalate xs xss is the concatenation of xss after the insertion of xs between every pair of elements. <math>(length xss). intercalate obeys the law:
toList (intercalate xs xss) = intercalate (toList xs) (map toList xss)
intercalate xs xss is equivalent to (concat (intersperse xs xss)). It inserts the list xs in between the lists in xss and concatenates the result.
>>> intercalate ", " ["Lorem", "ipsum", "dolor"]
"Lorem, ipsum, dolor"
intercalate has the following laziness properties:
>>> take 5 (intercalate undefined ("Lorem" : undefined))
"Lorem"

>>> take 6 (intercalate ", " ("Lorem" : undefined))
"Lorem*** Exception: Prelude.undefined
Synonym for ointercalate
Insert ShortText inbetween list of ShortTexts.
>>> intercalate ", " []
""
>>> intercalate ", " ["foo"]
"foo"
>>> intercalate ", " ["foo","bar","doo"]
"foo, bar, doo"
intercalate "" ts == concat ts
O(n) The intercalate function takes a separator Bytes and a list of Bytes and concatenates the list elements by interspersing the separator between each element.
O(n) The intercalate function takes a ByteStream and a list of ByteStreams and concatenates the list after interspersing the first argument between each element of the list.
intercalate xs xss is equivalent to (concat (intersperse xs xss)). It inserts the list xs in between the lists in xss and concatenates the result.
O(n) The intercalate function takes a JSString and a list of JSStrings and concatenates the list after interspersing the first argument between each element of the list.
intersperse followed by unfold and concat.
intercalate unf a str = unfoldMany unf $ intersperse a str
intersperse = intercalate (Unfold.function id)
unwords = intercalate Unfold.fromList " "
>>> Stream.toList $ Stream.intercalate Unfold.fromList " " $ Stream.fromList ["abc", "def", "ghi"]
"abc def ghi"
intercalate = mconcat .: intersperse
Concatenates the list of YiStrings after inserting the user-provided YiString between the elements. Empty YiStrings are not ignored and will end up as strings of length 1. If you don't want this, it's up to you to pre-process the list. Just as with intersperse, it is up to the user to pre-process the list.
Intercalate builders.
>>> intercalate ", " ["a", "b", "c"]
"a, b, c"
>>> intercalate ", " ["a"]
"a"
>>> intercalate ", " []
""
O(n) The intercalate function takes a OsString and a list of OsStrings and concatenates the list after interspersing the first argument between each element of the list.
O(n) The intercalate function takes a OsString and a list of OsStrings and concatenates the list after interspersing the first argument between each element of the list.
O(n) The intercalate function takes a OsString and a list of OsStrings and concatenates the list after interspersing the first argument between each element of the list.
intersperse followed by unfold and concat.
>>> intercalate u a = Stream.unfoldMany u . Stream.intersperse a

>>> intersperse = Stream.intercalate Unfold.identity

>>> unwords = Stream.intercalate Unfold.fromList " "
>>> input = Stream.fromList ["abc", "def", "ghi"]

>>> Stream.fold Fold.toList $ Stream.intercalate Unfold.fromList " " input
"abc def ghi"
Combine the elements in the list using Exon, interspersing the separator between each pair of elements. Returns mempty for empty lists; use intercalate1 for NonEmpty or intercalateMay to avoid the Monoid requirement.
intercalate xs xss is equivalent to (mconcat (intersperse xs xss)). It inserts the list xs in between the lists in xss and concatenates the result.