[Haskell-beginners] Using my first map instance

Chaddaï Fouché chaddai.fouche at gmail.com
Sat Sep 29 11:36:52 CEST 2012

On Sat, Sep 29, 2012 at 2:44 AM, Darren Grant <therealkludgy at gmail.com> wrote:
> On Fri, Sep 28, 2012 at 4:57 PM, Sean Perry <shaleh at speakeasy.net> wrote:
>> Have you looked at http://www.haskell.org/haskellwiki/Euler_problems/11_to_20#Problem_14?
>> The page is full of interesting and fast solutions once you have worked out your own versions.
> Hah I didn't know the Haskell Wiki had a Project Euler page. I'll
> definitely be reviewing with that resource.
> I notice the use of Array instead of Map, and the careful use of
> unboxed types. :)

This comment is misleading, there are no unboxed type in this solution
(maybe the author meant that this compiled down to unboxed types with
optimisations but the Haskell code definitely use boxed types : Int
and Word32) though there's a little bit of parallelism involved (could
be improved).
The use of a functional (immutable) Array here makes perfect sense
since the keys are effectively an interval of Int... Note that my old
Array version rely on the laziness of the Array to make it work, this
is basically dynamic programming where the order of computation
appears natural but only because laziness means it will be determined
by the computation itself. This is perfectly functional, no need to
resort to any imperative style here (or most everywhere in project


More information about the Beginners mailing list