drop -package:vector

drop n xs returns the suffix of xs after the first n elements, or [] if n >= length xs. It is an instance of the more general genericDrop, in which n may be of any integral type.

Examples

>>> drop 6 "Hello World!"
"World!"
>>> drop 3 [1,2,3,4,5]
[4,5]
>>> drop 3 [1,2]
[]
>>> drop 3 []
[]
>>> drop (-1) [1,2]
[1,2]
>>> drop 0 [1,2]
[1,2]
drop n xs drops the first n elements off the front of the sequence xs.
O(1) drop n xs returns the suffix of xs after the first n elements, or empty if n > length xs.
O(n/c) drop n xs returns the suffix of xs after the first n elements, or empty if n > length xs.
O(n) drop n xs returns the suffix of xs after the first n elements, or empty if n > length xs. Note: copies the entire byte array
O(n) drop n, applied to a Text, returns the suffix of the Text after the first n characters, or the empty Text if n is greater than the length of the Text.
O(n) drop n, applied to a stream, returns the suffix of the stream after the first n characters, or the empty stream if n is greater than the length of the stream. Properties
unstream . drop n . stream = drop n
O(n) drop n, applied to a Text, returns the suffix of the Text after the first n characters, or the empty Text if n is greater than the length of the Text.
Drop a given number of entries in key order, beginning with the smallest keys.
drop n = fromDistinctAscList . drop n . toAscList
Elements of a sequence after the first i. If i is negative, drop i s yields the whole sequence. If the sequence contains fewer than i elements, the empty sequence is returned.
Drop a given number of elements in order, beginning with the smallest ones.
drop n = fromDistinctAscList . drop n . toAscList
Drop delimiters from the output.
dropWhile p xs returns the suffix remaining after takeWhile p xs.

Examples

>>> dropWhile (< 3) [1,2,3,4,5,1,2,3]
[3,4,5,1,2,3]
>>> dropWhile (< 9) [1,2,3]
[]
>>> dropWhile (< 0) [1,2,3]
[1,2,3]
The dropWhileEnd function drops the largest suffix of a list in which the given predicate holds for all elements.

Laziness

This function is lazy in spine, but strict in elements, which makes it different from reverse . dropWhile p . reverse, which is strict in spine, but lazy in elements. For instance:
>>> take 1 (dropWhileEnd (< 0) (1 : undefined))
[1]
>>> take 1 (reverse $ dropWhile (< 0) $ reverse (1 : undefined))
*** Exception: Prelude.undefined
but on the other hand
>>> last (dropWhileEnd (< 0) [undefined, 1])
*** Exception: Prelude.undefined
>>> last (reverse $ dropWhile (< 0) $ reverse [undefined, 1])
1

Examples

>>> dropWhileEnd isSpace "foo\n"
"foo"
>>> dropWhileEnd isSpace "foo bar"
"foo bar"

>>> dropWhileEnd (> 10) [1..20]
[1,2,3,4,5,6,7,8,9,10]
dropWhile p xs returns the suffix remaining after takeWhile p xs.
O(1) dropEnd n xs is equivalent to take (length xs - n) xs. Drops n elements from end of bytestring.
>>> dropEnd 3 "abcdefg"
"abcd"

>>> dropEnd 0 "abcdefg"
"abcdefg"

>>> dropEnd 4 "abc"
""
Similar to dropWhile, drops the longest (possibly empty) prefix of elements satisfying the predicate and returns the remainder.
Similar to dropWhileEnd, drops the longest (possibly empty) suffix of elements satisfying the predicate and returns the remainder. dropWhileEnd p is equivalent to reverse . dropWhile p . reverse.
dropSpace efficiently returns the ByteString argument with white space Chars removed from the front. It is more efficient than calling dropWhile for removing whitespace. I.e.
dropWhile isSpace == dropSpace
dropWhile p xs returns the suffix remaining after takeWhile p xs.
dropWhileEnd p xs returns the prefix remaining after takeWhileEnd p xs.
O(n) dropEnd n xs is equivalent to take (length xs - n) xs. Drops n elements from end of bytestring.
>>> dropEnd 3 "abcdefg"
"abcd"

>>> dropEnd 0 "abcdefg"
"abcdefg"

>>> dropEnd 4 "abc"
""
Similar to dropWhileEnd, drops the longest (possibly empty) suffix of elements satisfying the predicate and returns the remainder. dropWhileEnd p is equivalent to reverse . dropWhile p . reverse.
>>> {-# LANGUAGE OverloadedLists #-)

>>> dropWhileEnd even [1,2,3,4,6]
[1,2,3]
Similar to dropWhileEnd, drops the longest (possibly empty) suffix of elements satisfying the predicate and returns the remainder. dropWhileEnd p is equivalent to reverse . dropWhile p . reverse.