H. <[EMAIL PROTECTED]> writes: > Jon Fairbairn <jon.fairbairn <at> cl.cam.ac.uk> writes: > > The idea in Haskell is not to think of stepping through the > > array. Look at accumArray and ixmap. > > Thanks for your answer. > > But I can't really see how the calc-function can be written more efficiently > with accumArray or ixmap, perhaps you can write it as an example?
Well, for your example, neither is needed since you could write something like: upb = 10000 listArray (1,upb) (repeat False) //map (\n->(2^n,True)) [1..floor (logBase 2 $ fromIntegral upb)] or a = listArray (1,upb) (repeat False) b = a//map (\n->(2^n,not (a!(2^n)))) [1..floor (logBase 2 $ fromIntegral upb)] but the first one is obviously better, so it depends on what you really want to do. -- Jón Fairbairn [EMAIL PROTECTED] http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2007-05-07) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe