Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. The following is supposed to be initializing a 2D array but
it doesn't seem to work. (KC)
----------------------------------------------------------------------
Message: 1
Date: Tue, 31 Jul 2012 14:52:17 -0700
From: KC <[email protected]>
Subject: [Haskell-beginners] The following is supposed to be
initializing a 2D array but it doesn't seem to work.
To: haskell-cafe <[email protected]>, [email protected]
Message-ID:
<CAMLKXymNT7s4A9Maa-k0x=pcoqlledvpo716ppcaafdvcrq...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
newArr :: (Ix i) => i -> i -> e -> Array i e
newArr n m x = listArray (n,m) (repeat
<http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:repeat>
x)
-----
Prelude <http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html>
Data.Array> newArr 0 10 0
array (0,10)
[(0,0),(1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0),(9,0),(10,0)]
Prelude <http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html>
Data.Array> newArr (0,0) (5,5) 0
array ((0,0),(5,5))
[((0,0),0),((0,1),0),((0,2),0),((0,3),0),((0,4),0),((0,5),0),((1,0),0),((1,1),0),((1,2),0),((1,3),0),((1,4),0),((1,5),0),((2,0),0),((2,1),0),((2,2),0),((2,3),0),((2,4),0),((2,5),0),((3,0),0),((3,1),0),((3,2),0),((3,3),0),((3,4),0),((3,5),0),((4,0),0),((4,1),0),((4,2),0),((4,3),0),((4,4),0),((4,5),0),((5,0),0),((5,1),0),((5,2),0),((5,3),0),((5,4),0),((5,5),0)]
All I am getting is this:
array ((1,5),(1,5)) [((1,5),1.0)]
Maybe the behaviour of ghc was changed since the article was written.
--
--
Regards,
KC
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120731/cf2b0c59/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 49, Issue 36
*****************************************