Matt McCutchen's Web Site
/
match
/
match.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add command-line interface ./match (adapted from POPL 2012 version).
[match/match.git]
/
program
/
ArrayStuff.hs
diff --git
a/program/ArrayStuff.hs
b/program/ArrayStuff.hs
index
ceb7516
..
df0a969
100644
(file)
--- a/
program/ArrayStuff.hs
+++ b/
program/ArrayStuff.hs
@@
-15,6
+15,9
@@
array2DtoListOfLists arr =
let ((xlo, ylo), (xhi, yhi)) = bounds arr in
map (\x -> map (\y -> arr ! (x, y)) $ range (ylo, yhi)) $ range (xlo, xhi)
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))
-- 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))