:: [a] -> [a] -> Bool -package:base-prelude

True if length xs == length ys
True if length xs <= length ys
True if length xs < length ys
Check whether two lists with different element types have equal length. It holds
\(Shape xs) (List ys) -> equalLength xs ys == (length xs == length ys)
but equalLength is more efficient.
lessOrEqualLength x y is almost the same as compareLength x y <= EQ, but
>>> lessOrEqualLength "" undefined
True
whereas compareLength [] undefined <= EQ = undefined.
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 isSuffixOf function takes two lists and returns True iff the first list is a suffix of the second.

Examples

>>> "ld!" `isSuffixOf` "Hello World!"
True
>>> "World" `isSuffixOf` "Hello World!"
False
The second list must be finite; however the first list may be infinite:
>>> [0..] `isSuffixOf` [0..99]
False
>>> [0..99] `isSuffixOf` [0..]
* Hangs forever *
The isInfixOf function takes two lists and returns True iff the first list is contained, wholly and intact, anywhere within the second.

Examples

>>> isInfixOf "Haskell" "I really like Haskell."
True
>>> isInfixOf "Ial" "I really like Haskell."
False
For the result to be True, the first list must be finite; for the result to be False, the second list must be finite:
>>> [20..50] `isInfixOf` [0..]
True
>>> [0..] `isInfixOf` [20..50]
False
>>> [0..] `isInfixOf` [0..]
* Hangs forever *
The isSubsequenceOf function takes two lists and returns True if all the elements of the first list occur, in order, in the second. The elements do not have to occur consecutively. isSubsequenceOf x y is equivalent to x `elem` (subsequences y). Note: isSubsequenceOf is often used in infix form.

Examples

>>> "GHC" `isSubsequenceOf` "The Glorious Haskell Compiler"
True
>>> ['a','d'..'z'] `isSubsequenceOf` ['a'..'z']
True
>>> [1..10] `isSubsequenceOf` [10,9..0]
False
For the result to be True, the first list must be finite; for the result to be False, the second list must be finite:
>>> [0,2..10] `isSubsequenceOf` [0..]
True
>>> [0..] `isSubsequenceOf` [0,2..10]
False
>>> [0,2..] `isSubsequenceOf` [0..]
* Hangs forever*
Are two lists disjoint, with no elements in common.
disjoint [1,2,3] [4,5] == True
disjoint [1,2,3] [4,1] == False
Returns true if the given list starts with the specified elements; false otherwise. (This is an alias for isPrefixOf.) Example:
startswith "He" "Hello" -> True
Returns true if the given list ends with the specified elements; false otherwise. (This is an alias for isSuffixOf.) Example:
endswith "lo" "Hello" -> True
Returns true if the given parameter is a sublist of the given list; false otherwise. Alias for isInfixOf. Example:
contains "Haskell" "I really like Haskell." -> True
contains "Haskell" "OCaml is great." -> False
Returns true if the given list contains any of the elements in the search list.
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 *
The isSuffixOf function takes two lists and returns True iff the first list is a suffix of the second.
>>> "ld!" `isSuffixOf` "Hello World!"
True

>>> "World" `isSuffixOf` "Hello World!"
False
The second list must be finite; however the first list may be infinite:
>>> [0..] `isSuffixOf` [0..99]
False

>>> [0..99] `isSuffixOf` [0..]
* Hangs forever *
The isInfixOf function takes two lists and returns True iff the first list is contained, wholly and intact, anywhere within the second.
>>> isInfixOf "Haskell" "I really like Haskell."
True

>>> isInfixOf "Ial" "I really like Haskell."
False
For the result to be True, the first list must be finite; for the result to be False, the second list must be finite:
>>> [20..50] `isInfixOf` [0..]
True

>>> [0..] `isInfixOf` [20..50]
False

>>> [0..] `isInfixOf` [0..]
* Hangs forever *
The isSubsequenceOf function takes two lists and returns True if all the elements of the first list occur, in order, in the second. The elements do not have to occur consecutively. isSubsequenceOf x y is equivalent to elem x (subsequences y).
>>> isSubsequenceOf "GHC" "The Glorious Haskell Compiler"
True

>>> isSubsequenceOf ['a','d'..'z'] ['a'..'z']
True

>>> isSubsequenceOf [1..10] [10,9..0]
False
For the result to be True, the first list must be finite; for the result to be False, the second list must be finite:
>>> [0,2..10] `isSubsequenceOf` [0..]
True

>>> [0..] `isSubsequenceOf` [0,2..10]
False

>>> [0,2..] `isSubsequenceOf` [0..]
* Hangs forever*
A number of VCS systems uniquely identify a particular revision or change via a cryptographic hash of some sort. These hashs can be very long, and so systems like Git and Darcs don't require the entire hash - a *unique prefix*. Thus a definition of hash equality is ==, certainly, but also simply whether either is a prefix of the other. If both are reasonably long, then the likelihood the shorter one is not a unique prefix of the longer (that is, clashes with another hash) is small. The burden of proof is on the caller to not pass a uselessly short short-hash like '1', however.