isInfixOf
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 *
Check whether one string is a substring of another.
Check whether one string is a substring of another.
O(n+m) The
isInfixOf function takes two
Texts and
returns
True if and only if the first is contained, wholly and
intact, anywhere within the second.
In (unlikely) bad cases, this function's time complexity degrades
towards
O(n*m).
O(n+m) The
isInfixOf function takes two
Texts and
returns
True if and only if the first is contained, wholly and
intact, anywhere within the second.
This function is strict in its first argument, and lazy in its second.
In (unlikely) bad cases, this function's time complexity degrades
towards
O(n*m).
Check whether one string is a substring of another. isInfixOf p
s is equivalent to not (null (findSubstrings p s)).
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
O(n+m) The
isInfixOf function takes two
Texts and
returns
True iff the first is contained, wholly and intact,
anywhere within the second.
In (unlikely) bad cases, this function's time complexity degrades
towards
O(n*m).
O(n+m) The
isInfixOf function takes two
Texts and
returns
True iff the first is contained, wholly and intact,
anywhere within the second.
This function is strict in its first argument, and lazy in its second.
In (unlikely) bad cases, this function's time complexity degrades
towards
O(n*m).
isInfixOf takes two sequences and returns
true if the
first sequence is contained, wholly and intact, anywhere within the
second.
Is the first argument an infix of the second argument?
Uses the Rabin-Karp algorithm: expected time O(n+m),
worst-case O(nm).
True when the first list is wholly containted within the second
The
isInfixOf function takes two
JSStrings and returns
True iff the first is contained, wholly and intact, anywhere
within the second.
Complexity depends on how the JavaScript engine implements
String.prototype.find.
Returns
True if the first stream is an infix of the second. A
stream is considered an infix of itself.
Stream.isInfixOf (Stream.fromList "hello") (Stream.fromList "hello" :: SerialT IO Char)
True
Space:
O(n) worst case where
n is the length of the
infix.
Pre-release
Requires Storable constraint
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 *
Check whether one string is a substring of another.
Check whether one string is a substring of another.
Check whether one string is a substring of another.
Returns
True if the first stream is an infix of the second. A
stream is considered an infix of itself.
>>> s = Stream.fromList "hello" :: Stream IO Char
>>> Stream.isInfixOf s s
True
Space:
O(n) worst case where
n is the length of the
infix.
Pre-release
Requires Storable constraint
Check whether the first string is contains within the second string.
TODO: implemented the naive way and thus terribly inefficient,
reimplement properly
Takes two collections and returns True iff the first collection is an
infix of the second.
Takes two collections and returns True iff the first collection is an
infix of the second.
isInfixOf sub l. Does
l contain the
subsequence
sub?
>>> prove $ \(l1 :: SList Integer) l2 l3 -> l2 `isInfixOf` (l1 ++ l2 ++ l3)
Q.E.D.
>>> prove $ \(l1 :: SList Integer) l2 -> l1 `isInfixOf` l2 .&& l2 `isInfixOf` l1 .<=> l1 .== l2
Q.E.D.
>>> prove $ \(s1 :: SString) s2 s3 -> s2 `isInfixOf` (s1 ++ s2 ++ s3)
Q.E.D.
>>> prove $ \(s1 :: SString) s2 -> s1 `isInfixOf` s2 .&& s2 `isInfixOf` s1 .<=> s1 .== s2
Q.E.D.
Returns true if the first string appears somewhere in the second
string.