
Thinking about Bird's handling of Sudoku; it may be efficiently
possible to represent colonies as lists (or trees).
Then one just has to consider the merging and splitting of colonies.
Usually, all the space in a cell array is not used anyway. :)
On Fri, Jan 4, 2013 at 11:27 PM, KC
You might want to look at the chapter on Sudoku (and the whole book) in "Pearls of Functional Algorithm Design" by Richard Bird.
On Fri, Jan 4, 2013 at 12:41 PM, Емануела Моллова
wrote: Hello all! :) I'm new to Haskell and I would like to try to implement a simple version of Game of Life. I can imagine it in C++ for example, but I have a little difficulties in Haskell. All I can think for is a mutable array with all elements - 0 in the beginning and the user to be able to write in the coordinates of the cells, which are alive and this cells to become 1. Then to iterate through the array (but I'm not sure if I can iterate, there is no 'while' here) and to make the changes (but maybe I will need a new array for the changes, because when the first change happens, it will affect the result). Also I was thinking of how to make it visible, so I tried to make all 0-s red and all 1-s green, and after each iteration to clear the screen with ANSI so that it looks a bit like animation, but none of these ideas work... Here is an orientation in my ideas:
import Data.Array.IO import System.Console.ANSI
main :: IO () main = do arr <- newArray ((1,1), (10,10)) 0 :: IO (IOArray (Int, Int) Int) writeAraay arr (1,1) 1 a <- readArray (1,1) setSGR [SetColor Foreground Dull Red] putStr [a]
Could you please suggest me what is a good place to store the information about my cells (mutable, unmutable array, lists, tuples...) and any ideas and tutorials at all would be really appreciated! Thank you very much in advance! :)
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- -- Regards, KC
-- -- Regards, KC