[Haskell-beginners] First code review

Emanuel Koczwara poczta at emanuelkoczwara.pl
Sun Feb 24 00:15:05 CET 2013


Dnia 2013-02-23, sob o godzinie 17:35 -0500, Brent Yorgey pisze:
> On Sat, Feb 23, 2013 at 04:39:53PM +0100, Emanuel Koczwara wrote:
> > Hi,
> > 
> > Note: Following code is a solution for a problem from hackerrank.com
> > (Category: Artifical Intelligence / Single Player Games / Bot saves
> > princess).
> Looks pretty good overall.  One note is that using lists of lists for
> Grid and Heuristic will be slow, especially Heuristic since you do
> lots of repeated lookups.  For small grids it really doesn't make much
> difference, but if you wanted to run it on larger grids you might
> notice.  Since both the Grid and Heuristic values are created once and
> then used in a read-only fasion, this is a perfect opportunity to use
> arrays: see 
>   http://hackage.haskell.org/packages/archive/array/latest/doc/html/Data-Array.html
> Using read-only arrays is really quite simple (as opposed to
> read/write arrays which require a monad of some sort).

  Thank you, I will try Arrays. Handling list of lists is very hard for
me. Please look at this code: http://hpaste.org/82925 (indexedGrid and
getDirty). In C/C++ it's very natural for me, here it looks like i'm
missing something.


More information about the Beginners mailing list