split
splitAt n xs returns a tuple xs prefix of length n and second element is the remainder of the list:
> splitAt 6 "Hello World!" == ("Hello ","World!")
> splitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
> splitAt 1 [1,2,3] == ([1],[2,3])
> splitAt 3 [1,2,3] == ([1,2,3],[])
> splitAt 4 [1,2,3] == ([1,2,3],[])
> splitAt 0 [1,2,3] == ([],[1,2,3])
> splitAt (-1) [1,2,3] == ([],[1,2,3])
It is equivalent to (take n xs, drop n xs). splitAt is an instance of the more general Data.List.genericSplitAt, in which n may be of any integral type.
Splits a type constructor application
O(n) Splits a Text into components delimited by separators, The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. eg.
> split (=='a') "aabbaca" == ["","","bb","c",""]
> split (=='a') "" == [""]
O(n) Splits a Text into components delimited by separators, The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. eg.
> split (=='a') "aabbaca" == ["","","bb","c",""]
> split (=='a') [] == [""]
O(n) Break a ByteString into pieces separated by the byte argument, consuming the delimiter. I.e.
> split '\n' "a\nb\nd\ne" == ["a","b","d","e"]
> split 'a' "aXaXaXa" == ["","X","X","X",""]
> split 'x' "x" == ["",""]
and
> intercalate [c] . split c == id
> split == splitWith . (==)
As for all splitting functions in this library, this function does not copy the substrings, it just constructs new ByteStrings that are slices of the original.
O(n) Break a ByteString into pieces separated by the byte argument, consuming the delimiter. I.e.
> split '\n' "a\nb\nd\ne" == ["a","b","d","e"]
> split 'a' "aXaXaXa" == ["","X","X","X"]
> split 'x' "x" == ["",""]
and
> intercalate [c] . split c == id
> split == splitWith . (==)
As for all splitting functions in this library, this function does not copy the substrings, it just constructs new ByteStrings that are slices of the original.
O(min(n,W)). The expression (split x set) is a pair (set1,set2) of set less than x and set2 comprises the elements of set greater than x.
> split 3 (fromList [1..5]) == (fromList [1,2], fromList [4,5])
O(min(n,W)). The expression (split k map) is a pair (map1,map2) than k and all keys in map2 larger than k. Any key equal to k is found in neither map1 nor map2.
> split 2 (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3,"b"), (5,"a")])
> split 3 (fromList [(5,"a"), (3,"b")]) == (empty, singleton 5 "a")
> split 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")
> split 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", empty)
> split 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], empty)
O(n) Break a ByteString into pieces separated by the byte argument, consuming the delimiter. I.e.
> split '\n' "a\nb\nd\ne" == ["a","b","d","e"]
> split 'a' "aXaXaXa" == ["","X","X","X",""]
> split 'x' "x" == ["",""]
and
> intercalate [c] . split c == id
> split == splitWith . (==)
As for all splitting functions in this library, this function does not copy the substrings, it just constructs new ByteStrings that are slices of the original.
O(log n). The expression (split x set) is a pair (set1,set2) of set less than x and set2 comprises the elements of set greater than x.
O(log n). The expression (split k map) is a pair (map1,map2) than k and the keys in map2 larger than k. Any key equal to k is found in neither map1 nor map2.
> split 2 (fromList [(5,"a"), (3,"b")]) == (empty, fromList [(3,"b"), (5,"a")])
> split 3 (fromList [(5,"a"), (3,"b")]) == (empty, singleton 5 "a")
> split 4 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", singleton 5 "a")
> split 5 (fromList [(5,"a"), (3,"b")]) == (singleton 3 "b", empty)
> split 6 (fromList [(5,"a"), (3,"b")]) == (fromList [(3,"b"), (5,"a")], empty)
Combinator library and utility functions for splitting lists.
Version 0.1.4.2
Split a big audio file into pieces at positions of silence
Version 0.1.1
O(log(min(i,n-i))). Split a sequence at a given position. splitAt i s = (take i s, drop i s).
O(n) splitAt n t returns a pair whose first element is a prefix of t of length n, and whose second is the remainder of the string. It is equivalent to (take n t, drop n t).
Show more results