elem package:base-prelude

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 *
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.
>>> elemIndex 4 [0..]
Just 4
The elemIndices function extends elemIndex, by returning the indices of all elements equal to the query element, in ascending order.
>>> elemIndices 'o' "Hello World"
[4,7]
An attempt was made to evaluate an element of an array that had not been initialized.
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 *
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