Skip to content
Snippets Groups Projects
Commit 7f0f325c authored by Simon Marlow's avatar Simon Marlow
Browse files

[project @ 1997-12-19 12:22:57 by simonm]

Move array tests from ghc/lib to ghc/tests and put them in our test
framework.
parent 9b422952
No related branches found
No related tags found
No related merge requests found
-- Array - array difference operator
--
--
module Main(main) where
import Array
import Ix
hist :: (Ix a, Num b) => (a,a) -> [a] -> Array a b
hist bnds is = accumArray (+) 0 bnds [(i,1) | i <- is , inRange bnds i]
main =
let
a1 = hist (0,10) (concat $ take 2 $ repeat [1..20])
in
print a1 >>
print (a1 // [ (i,0) | i<-[0..10], odd i])
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/target.mk
-- Array map operations
--
--
module Main(main) where
import Array
import Char
main =
let
a1 = array (0,10) (zip [0..10] ['a'..'z'])
in
print a1 >>
print (map (toUpper) a1) >>
print (ixmap (3,8) (+1) a1)
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/target.mk
array (0, 10) [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e'), (5, 'f'), (6, 'g'), (7, 'h'), (8, 'i'), (9, 'j'), (10, 'k')]
array (0, 10) [(0, 'A'), (1, 'B'), (2, 'C'), (3, 'D'), (4, 'E'), (5, 'F'), (6, 'G'), (7, 'H'), (8, 'I'), (9, 'J'), (10, 'K')]
array (3, 8) [(3, 'e'), (4, 'f'), (5, 'g'), (6, 'h'), (7, 'i'), (8, 'j')]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment