[a] -> a -> Maybe Int
The elemIndex function returns the index of the first element in the given list which is equal (by ==) to the query element, or Nothing if there is no such element.
Deprecated: findSubstring is deprecated in favour of breakSubstring.
Get the first index of a substring in another string, or Nothing if the string is not found. findSubstring p s is equivalent to listToMaybe (findSubstrings p s).
O(log n). Lookup the index of an element, which is its zero-based index in the sorted sequence of elements. The index is a number from 0 up to, but not including, the size of the set.
> isJust (lookupIndex 2 (fromList [5,3])) == False
> fromJust (lookupIndex 3 (fromList [5,3])) == 0
> fromJust (lookupIndex 5 (fromList [5,3])) == 1
> isJust (lookupIndex 6 (fromList [5,3])) == False
elemIndexL finds the leftmost index of the specified element, if it is present, and otherwise Nothing.
elemIndexR finds the rightmost index of the specified element, if it is present, and otherwise Nothing.
convert month and day in the Gregorian or Julian calendars to day of year. First arg is leap year flag
Ignore an invalid input, substituting nothing in the output.
asTypeOf is a type-restricted version of const. It is usually used as an infix operator, and its typing forces its first argument (which is usually overloaded) to have the same type as the second.
List index (subscript) operator, starting from 0. It is an instance of the more general Data.List.genericIndex, which takes an index of any integral type.
When called, trace outputs the string in its first argument, before returning the second argument as its result. The trace function is not referentially transparent, and should only be used for debugging, or for monitoring execution. Some implementations of trace may decorate the string that's output to indicate that you're tracing. The function is implemented on top of putTraceMsg.
O(n+m) The count function returns the number of times the query string appears in the given Text. An empty query string is invalid, and will cause an error to be raised.
In (unlikely) bad cases, this function's time complexity degrades towards O(n*m).
The foldM function is analogous to foldl, except that its result is encapsulated in a monad. Note that foldM works from left-to-right over the list arguments. This could be an issue
> foldM f a1 [x1, x2, ..., xm]
> a2 <- f a1 x1
> a3 <- f a2 x2
> f am xm
If right-to-left evaluation is required, the input list should be reversed.
O(log n). Return the index of an element, which is its zero-based index in the sorted sequence of elements. The index is a number from 0 up to, but not including, the size of the set. Calls error when the element is not a member of the set.
> findIndex 2 (fromList [5,3]) Error: element is not in the set
> findIndex 3 (fromList [5,3]) == 0
> findIndex 5 (fromList [5,3]) == 1
> findIndex 6 (fromList [5,3]) Error: element is not in the set
foldl, applied to a binary operator, a starting value (typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
> foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
The list must be finite.
A strict version of foldl.
Show more results