isPrefixOf

The isPrefixOf function takes two lists and returns True iff the first list is a prefix of the second.

Examples

>>> "Hello" `isPrefixOf` "Hello World!"
True
>>> "Hello" `isPrefixOf` "Wello Horld!"
False
For the result to be True, the first list must be finite; False, however, results from any mismatch:
>>> [0..] `isPrefixOf` [1..]
False
>>> [0..] `isPrefixOf` [0..99]
False
>>> [0..99] `isPrefixOf` [0..]
True
>>> [0..] `isPrefixOf` [0..]
* Hangs forever *
isPrefixOf shortcuts when the first argument is empty:
>>> isPrefixOf [] undefined
True
The isPrefixOf function returns True if the first argument is a prefix of the second.
O(n) The isPrefixOf function takes two ByteStrings and returns True if the first is a prefix of the second.
O(n) The isPrefixOf function takes two ByteStrings and returns True iff the first is a prefix of the second.
O(n) The isPrefixOf function takes two ShortByteStrings and returns True iff the first is a prefix of the second.
O(n) The isPrefixOf function takes two Texts and returns True if and only if the first is a prefix of the second.
O(n) The isPrefixOf function takes two Streams and returns True if and only if the first is a prefix of the second. Properties
isPrefixOf (stream t1) (stream t2) = isPrefixOf t1 t2
The isPrefixOf function takes two lists and returns True iff the first list is a prefix of the second.
>>> "Hello" `isPrefixOf` "Hello World!"
True

>>> "Hello" `isPrefixOf` "Wello Horld!"
False
For the result to be True, the first list must be finite; False, however, results from any mismatch:
>>> [0..] `isPrefixOf` [1..]
False

>>> [0..] `isPrefixOf` [0..99]
False

>>> [0..99] `isPrefixOf` [0..]
True

>>> [0..] `isPrefixOf` [0..]
* Hangs forever *
isPrefixOf shortcuts when the first argument is empty:
>>> isPrefixOf [] undefined
True
The isPrefixOf function takes two lists and returns True iff the first list is a prefix of the second.
>>> "Hello" `isPrefixOf` "Hello World!"
True
>>> "Hello" `isPrefixOf` "Wello Horld!"
False
O(n) The isPrefixOf function takes two Texts and returns True iff the first is a prefix of the second. Subject to fusion.
isPrefixOf takes two sequences and returns True if the first sequence is a prefix of the second.
Tests whether the first ShortText is a prefix of the second ShortText
>>> isPrefixOf "ab" "abcdef"
True
>>> isPrefixOf "ac" "abcdef"
False
isPrefixOf "" t == True
isPrefixOf t t == True
Is the first argument a prefix of the second argument?
True when the first list is at the beginning of the second.
O(n) The isPrefixOf function takes two JSStrings and returns True iff the first is a prefix of the second. Subject to fusion.
Returns True if the first stream is the same as or a prefix of the second. A stream is a prefix of itself.
>>> Stream.isPrefixOf (Stream.fromList "hello") (Stream.fromList "hello" :: SerialT IO Char)
True
The isPrefixOf function takes two lists and returns True iff the first list is a prefix of the second.
>>> "Hello" `isPrefixOf` "Hello World!"
True

>>> "Hello" `isPrefixOf` "Wello Horld!"
False
For the result to be True, the first list must be finite; False, however, results from any mismatch:
>>> [0..] `isPrefixOf` [1..]
False

>>> [0..] `isPrefixOf` [0..99]
False

>>> [0..99] `isPrefixOf` [0..]
True

>>> [0..] `isPrefixOf` [0..]
* Hangs forever *
O(n) The isPrefixOf function takes two Vector and returns True iff the first is a prefix of the second.
The isPrefix function returns True if the first argument is a prefix of the second.
O(n) The isPrefixOf function takes two OsStrings and returns True
O(n) The isPrefixOf function takes two ShortByteStrings and returns True
O(n) The isPrefixOf function takes two OsStrings and returns True
O(n) The isPrefixOf function takes two OsStrings and returns True
Returns True if the first stream is the same as or a prefix of the second. A stream is a prefix of itself.
>>> Stream.isPrefixOf (Stream.fromList "hello") (Stream.fromList "hello" :: Stream IO Char)
True