+++ /dev/null
--- Simple array creation
-
-import Array
-
-main =
- let a1 = array (1,3) (zip [2,3,1] ['a'..'d']) in
- print a1
-
--- Result:
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
+++ /dev/null
--- Array creation, (index,value) list with duplicates.
---
--- Haskell library report 1.3 (and earlier) specifies
--- that `array' values created with lists containing dups,
--- are undefined ( _|_ ).
---
--- GHC-2.02 (and earlier) does not flag this as such, the
--- last (index,value) is instead used.
---
--- The report also specifies `array' is spine strict in
--- the (index,value) list argument and to check the
--- validity of the index values upon creation, it also
--- strict for the indices. To test this, we do (a!1)
--- twice, expecting to see the same value..
---
-import Array
-
-main =
- let a1 = array (1,3) (zip (1:[1..3]) ['a'..'d']) in
- print (a1!1) >>
- print a1 >>
- print (a1!1)
-
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
+++ /dev/null
--- Array creation, (index,value) list with out of bound index.
---
--- Haskell library report 1.3 (and earlier) specifies
--- that `array' values created with lists containing out-of-bounds indices,
--- are undefined ( _|_ ).
---
--- GHC implementation of `array' catches this (or, rather,
--- `index' does) - the argument list to `array' is defined
--- to have its spine be evaluated - so the indexing below
--- should cause a failure.
---
-import Array
-
-main =
- let a1 = array (1,3) (zip ([1..4]) ['a'..'d']) in
- print (a1!2)
-
-
-
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
+++ /dev/null
--- Array - accessing undefined element
---
--- Sample Haskell implementation in the 1.3 Lib report defines
--- this as being undefined/error.
-
-import Array
-
-main =
- let a1 = array (1,3) (zip ([1,2]) ['a'..'d']) in
- print (a1!3)
-
--- output: Fail: (Array.!): undefined array element
-
-
-
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
+++ /dev/null
--- Array - recurrences
---
--- array does not evaluate the elements.
---
-import Array
-
-main =
- let
- a1 = array (1,100) ((1,1::Integer):[(i,i*a1!(i-1))|i<-[2..100]])
- in
- print a1
-
---
-
-
-
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
+++ /dev/null
--- Array - empty arrays
---
--- print a couple of them to try to expose empty arrays
--- to a GC or two.
-import Array
-
-main =
- let
- a1 = array (1,0) []
- in
- print (take 300 $ repeat (a1 :: Array Int Int))
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
+++ /dev/null
--- Array - accessing empty arrays
---
--- empty arrays are legal, but indexing them is undefined!
---
-import Array
-
-main =
- let
- a1 = array (1,0) [(1,'a')]
- in
- print (a1!0)
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
+++ /dev/null
--- Array - out-of-range (index,value) pairs
---
--- supplying a list containing one or more pairs
--- with out-of-range index is undefined.
---
---
-import Array
-
-main =
- let
- a1 = array (1,0) []
- a2 = array (0,1) (zip [0..] ['a'..'z'])
- in
- print (a1::Array Int Int) >> print a2
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
+++ /dev/null
--- Array - derived ops
---
--- testing the well-behavedness of
--- derived ops for empty and non-empty arrays
---
-import Array
-
-main =
- let
- a1 = array (1,0) ([]::[(Int,Int)])
- a2 = array (1,26) (zip [1..] ['a'..'z'])
-
- dump a = (bounds a, indices a, elems a, assocs a)
- in
- print (dump a1) >>
- print (dump a2)
-
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
+++ /dev/null
---
--- Array - accumulated arrays
---
---
-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
-
-
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
+++ /dev/null
--- 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])
-
-
-
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
+++ /dev/null
--- 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)
-
-
-
-
+++ /dev/null
-TOP=../../../..
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/target.mk
--- /dev/null
+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')]