[Haskell-beginners] Laziness, automatic memoization and arrays

Oscar Picasso oscarpicasso at gmail.com
Sun Aug 28 01:03:00 CEST 2011


Hi,

I have a very simple question about laziness, memoization and arrays.
If I have:

import Data.Array

a = listArray (1,10) $ map (\x -> (x*x)) [1..10]

main = do
  print c ! 4
  print c ! 4
  print c ! 4


Can we assume that the operation 4 * 4 is evaluated only once, when
first calling print c ! 4 in the main method?

Oscar



More information about the Beginners mailing list