Rename "desirability" to "preference" (much less awkward), with the
[match/match.git] / program / ArrayStuff.hs
index 8fcced9..df0a969 100644 (file)
@@ -15,6 +15,12 @@ array2DtoListOfLists arr =
        let ((xlo, ylo), (xhi, yhi)) = bounds arr in
        map (\x -> map (\y -> arr ! (x, y)) $ range (ylo, yhi)) $ range (xlo, xhi)
 
+listOfListsToArray2D ll =
+       listArray ((0, 0), (length ll - 1, length (head ll) - 1)) $ concat ll
+
 -- Use instead of amap when the array implementation needs to change.
 -- E.g., mapping an unboxed array to an array whose elements must be boxed.
 amap2 f arr = funcArray (bounds arr) (\i -> f (arr ! i))
+
+-- Like amap2 but the mapping function is also passed the index.
+aixmap f arr = funcArray (bounds arr) (\i -> f i (arr ! i))