elem package:base

Does the element occur in the structure? Note: elem is often used in infix form.

Examples

Basic usage:
>>> 3 `elem` []
False
>>> 3 `elem` [1,2]
False
>>> 3 `elem` [1,2,3,4,5]
True
For infinite structures, the default implementation of elem terminates if the sought-after value exists at a finite distance from the left side of the structure:
>>> 3 `elem` [1..]
True
>>> 3 `elem` ([4..] ++ [3])
* Hangs forever *
elem is the list membership predicate, usually written in infix form, e.g., x `elem` xs. For the result to be False, the list must be finite; True, however, results from an element equal to x found at a finite index of a finite or infinite list.

Examples

>>> 3 `elem` []
False
>>> 3 `elem` [1,2]
False
>>> 3 `elem` [1,2,3,4,5]
True
>>> 3 `elem` [1..]
True
>>> 3 `elem` [4..]
* Hangs forever *
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. For the result to be Nothing, the list must be finite.

Examples

>>> elemIndex 4 [0..]
Just 4
>>> elemIndex 'o' "haskell"
Nothing
>>> elemIndex 0 [1..]
* hangs forever *
The elemIndices function extends elemIndex, by returning the indices of all elements equal to the query element, in ascending order.

Examples

>>> elemIndices 'o' "Hello World"
[4,7]
>>> elemIndices 1 [1, 2, 3, 1, 2, 3]
[0,3]
The list of elements of an array in index order.
notElem is the negation of elem.

Examples

Basic usage:
>>> 3 `notElem` []
True
>>> 3 `notElem` [1,2]
True
>>> 3 `notElem` [1,2,3,4,5]
False
For infinite structures, notElem terminates if the value exists at a finite distance from the left side of the structure:
>>> 3 `notElem` [1..]
False
>>> 3 `notElem` ([4..] ++ [3])
* Hangs forever *
An attempt was made to evaluate an element of an array that had not been initialized.
Does the element occur in the structure?

Examples

Basic usage:
>>> bielem 42 (17, 42)
True
>>> bielem 42 (17, 43)
False
>>> bielem 42 (Left 42)
True
>>> bielem 42 (Right 13)
False
>>> bielem 42 (BiList [1..5] [1..100])
True
>>> bielem 42 (BiList [1..5] [1..41])
False
binotElem is the negation of bielem.

Examples

Basic usage:
>>> binotElem 42 (17, 42)
False
>>> binotElem 42 (17, 43)
True
>>> binotElem 42 (Left 42)
False
>>> binotElem 42 (Right 13)
True
>>> binotElem 42 (BiList [1..5] [1..100])
False
>>> binotElem 42 (BiList [1..5] [1..41])
True
Read a value from a memory area regarded as an array of values of the same kind. The first argument specifies the start address of the array and the second the index into the array (the first element of the array has index 0). The following equality holds,
peekElemOff addr idx = IOExts.fixIO $ \result ->
peek (addr `plusPtr` (idx * sizeOf result))
Note that this is only a specification, not necessarily the concrete implementation of the function.
Write a value to a memory area regarded as an array of values of the same kind. The following equality holds:
pokeElemOff addr idx x =
poke (addr `plusPtr` (idx * sizeOf x)) x
A left fold over the elements with no starting value
A left fold over the elements
A strict left fold over the elements
A right fold over the elements with no starting value
A right fold over the elements
A strict right fold over the elements
The number of elements in the array.