arr003.hs 533 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
-- !!! 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.
--
12
import Data.Array
13
14
15
16

main =
 let a1 = array (1::Int,3) (zip ([1..4]) ['a'..'d']) in
 print (a1!2)