Copyright | (c) The University of Glasgow 2001 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | libraries@haskell.org |
Stability | provisional |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Basic non-strict arrays.
Note: The Data.Array.IArray module provides a more general interface
to immutable arrays: it defines operations with the same names as
those defined below, but with more general types, and also defines
Array
instances of the relevant classes. To use that more general
interface, import Data.Array.IArray but not Data.Array.
Synopsis
- module Data.Ix
- data Array i e
- array :: Ix i => (i, i) -> [(i, e)] -> Array i e
- listArray :: Ix i => (i, i) -> [e] -> Array i e
- accumArray :: Ix i => (e -> a -> e) -> e -> (i, i) -> [(i, a)] -> Array i e
- (!) :: Ix i => Array i e -> i -> e
- bounds :: Array i e -> (i, i)
- indices :: Ix i => Array i e -> [i]
- elems :: Array i e -> [e]
- assocs :: Ix i => Array i e -> [(i, e)]
- (//) :: Ix i => Array i e -> [(i, e)] -> Array i e
- accum :: Ix i => (e -> a -> e) -> Array i e -> [(i, a)] -> Array i e
- ixmap :: (Ix i, Ix j) => (i, i) -> (i -> j) -> Array j e -> Array i e
Immutable non-strict arrays
Haskell provides indexable arrays, which may be thought of as functions whose domains are isomorphic to contiguous subsets of the integers. Functions restricted in this way can be implemented efficiently; in particular, a programmer may reasonably expect rapid access to the components. To ensure the possibility of such an implementation, arrays are treated as data, not as general functions.
Since most array functions involve the class Ix
, this module is exported
from Data.Array so that modules need not import both Data.Array and
Data.Ix.
module Data.Ix
Instances
IArray Array e Source # | |
Defined in Data.Array.Base bounds :: Ix i => Array i e -> (i, i) Source # numElements :: Ix i => Array i e -> Int Source # unsafeArray :: Ix i => (i, i) -> [(Int, e)] -> Array i e Source # unsafeAt :: Ix i => Array i e -> Int -> e Source # unsafeReplace :: Ix i => Array i e -> [(Int, e)] -> Array i e Source # unsafeAccum :: Ix i => (e -> e' -> e) -> Array i e -> [(Int, e')] -> Array i e Source # unsafeAccumArray :: Ix i => (e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> Array i e Source # | |
Functor (Array i) | |
Foldable (Array i) | |
Defined in GHC.Internal.Data.Foldable fold :: Monoid m => Array i m -> m # foldMap :: Monoid m => (a -> m) -> Array i a -> m # foldMap' :: Monoid m => (a -> m) -> Array i a -> m # foldr :: (a -> b -> b) -> b -> Array i a -> b # foldr' :: (a -> b -> b) -> b -> Array i a -> b # foldl :: (b -> a -> b) -> b -> Array i a -> b # foldl' :: (b -> a -> b) -> b -> Array i a -> b # foldr1 :: (a -> a -> a) -> Array i a -> a # foldl1 :: (a -> a -> a) -> Array i a -> a # elem :: Eq a => a -> Array i a -> Bool # maximum :: Ord a => Array i a -> a # minimum :: Ord a => Array i a -> a # | |
Ix i => Traversable (Array i) | |
(Ix a, Read a, Read b) => Read (Array a b) | |
(Ix a, Show a, Show b) => Show (Array a b) | |
(Ix i, Eq e) => Eq (Array i e) | |
(Ix i, Ord e) => Ord (Array i e) | |
Defined in GHC.Internal.Arr |
Array construction
accumArray :: Ix i => (e -> a -> e) -> e -> (i, i) -> [(i, a)] -> Array i e #