@@ -14,10 +14,10 @@ into a list before operating on it, and then turning it back into an array.
14@docs fill, fromList, concat, set, updates, push
14@docs fill, fromList, concat, set, updates, push
16# Taking Arrays Apart
16# Taking Arrays Apart
17−@docs elements, indices, assocs, slice
17+@docs toList, toIndexedList, indices, slice
19# Mapping, folding, zipping
19# Mapping, folding, zipping
20−@docs map, assocMap, foldl, foldr, zip, zipWith
20+@docs map, indexMap, foldl, foldr, zip, zipWith
23import Native.Array
23import Native.Array
@@ -41,10 +41,10 @@ fromList = List.foldl (Native.Array.push) Native.Array.empty
42{-| Create a list of elements from an array.
42{-| Create a list of elements from an array.
44− elements (fromList [3,5,8]) == [3,5,8]
44+ toList (fromList [3,5,8]) == [3,5,8]
46−elements : Array a -> [a]
46+toList : Array a -> [a]
47−elements = Native.Array.elements
47+toList = Native.Array.toList
49{-| Create a list of the possible indices of an array.
49{-| Create a list of the possible indices of an array.
@@ -53,12 +53,13 @@ elements = Native.Array.elements
53indices : Array a -> [Int]
53indices : Array a -> [Int]
54indices a = [0..Native.Array.length a - 1]
54indices a = [0..Native.Array.length a - 1]
56+-- TODO: make this a native function.
56{-| Create a list of tuples (Index, Element) from an array.
57{-| Create a list of tuples (Index, Element) from an array.
58− assocs (fromList [3,5,8]) == [(0,3), (1,5), (2,8)]
59+ toIndexedList (fromList [3,5,8]) == [(0,3), (1,5), (2,8)]
60−assocs : Array a -> [(Int, a)]
61+toIndexedList : Array a -> [(Int, a)]
61−assocs a = List.zip (indices a) (Native.Array.elements a)
62+toIndexedList a = List.zip (indices a) (Native.Array.toList a)
63{-| Apply a function on every element in an array.
64{-| Apply a function on every element in an array.
@@ -67,12 +68,12 @@ assocs a = List.zip (indices a) (Native.Array.elements a)
67map : (a -> b) -> Array a -> Array b
68map : (a -> b) -> Array a -> Array b
68map = Native.Array.map
69map = Native.Array.map
70−{-| Apply a function with an index on every element in an array.
71+{-| Apply a function on every element with its index as first argument.
72− assocMap (*) (fromList [5,5,5]) == fromList [0,5,10]
73+ indexedMap (*) (fromList [5,5,5]) == fromList [0,5,10]
74−assocMap : (Int -> a -> b) -> Array a -> Array b
75+indexedMap : (Int -> a -> b) -> Array a -> Array b
75−assocMap = Native.Array.assocMap
76+indexedMap = Native.Array.indexedMap
77{-| Reduce an array from the left.
78{-| Reduce an array from the left.
@@ -103,7 +104,7 @@ is longer, the extra elements are dropped.
104zipWith : (a -> b -> c) -> Array a -> Array b -> Array c
105zipWith : (a -> b -> c) -> Array a -> Array b -> Array c
105zipWith f a b =
106zipWith f a b =
106− fromList <| List.zipWith f (Native.Array.elements a) (Native.Array.elements b)
107+ fromList <| List.zipWith f (Native.Array.toList a) (Native.Array.toList b)
108{-| Return an empty array.
109{-| Return an empty array.
@@ -160,7 +161,7 @@ set = Native.Array.set
160 updates [(1,7),(2,8)] (fill 3 1) == fromList [1,7,8]
161 updates [(1,7),(2,8)] (fill 3 1) == fromList [1,7,8]
162updates : [(Int, a)] -> Array a -> Array a
163updates : [(Int, a)] -> Array a -> Array a
163−updates assocs array = List.foldl (uncurry Native.Array.set) array assocs
164+updates us array = List.foldl (uncurry Native.Array.set) array us
165{-| Slice an array given a range. The selection is inclusive, so the last
166{-| Slice an array given a range. The selection is inclusive, so the last
166element in the selection will also be in the new array. This may change in the
167element in the selection will also be in the new array. This may change in the