[Haskell-beginners] Searching for word in 2D array

Ozgur Akgun ozgurakgun at gmail.com
Fri Mar 23 16:45:59 CET 2012


On 23 March 2012 10:01, Nathan Hüsken <nathan.huesken at posteo.de> wrote:

> If I understand correctly, in this solution it is assumed that that a
> word must be a complete line (row column or diagonal), correct?
>

No it doesn't. See the "search" function and the use of isInfixOf there.


> I do not understand why a set is used. Couldn't just a list be used
> here, or is there some performance advantage I do not see?
>

You certainly can use a list in this case. However, if you do not care
about the number of times a word appears in a collection (which seemed to
be the case here), then using a Set might be a better idea.

You can implement the same thing using lists instead of sets and see it for
yourself :)


> I find it very difficult to estimate the performance of an haskell
> program. The other solution of Lorenzo Bolla utilizes Data.Vector.
> Does that give a performance advantage in this case?


I don't use a lot of Vectors, so no comment here.

Cheers,
Ozgur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120323/ea399dc7/attachment.htm>


More information about the Beginners mailing list