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

Nathan Hüsken nathan.huesken at posteo.de
Thu Mar 22 18:45:36 CET 2012


Hey,

I have the following problem. I have an 2D array of letters, like this:

b w y l
a i l q
h w r a
o q e d

Now I am searching for all occurrences of a specific word in this
array. The word can be horizontal, vertical or diagonal, like "bird"
is in the example above. I am a beginer at haskell and I do not know
where to start ...

OK, I would represent the word as an String == [Char] and my array as
[[Char]] (or would some kind of fixed size array make more sense?).

In an imperative program, I would just search for the first letter and
than check the rest of the word in all directions.
If I do this, I need direct indexing of the array.

Any advise in which direction to think?

Thanks!
Nathan



More information about the Beginners mailing list