[Haskell-beginners] life with Hutton 2ed

Sylvester Hazel sylvester.hazel at googlemail.com
Sat Jun 16 20:23:36 UTC 2018


I wonder why life/10.8 runs nonsensically on my PC even with
Language.Haskell.HsColour.ANSI import?
These cls and goto reappear in 11.7 that spoil the pleasure of
understanding.
Also putGrid/11.4 is unintuitive backsword engineering concoction that
teaches nothing, while it can be very intuitively written: putGrid g =
sequence_  [putStrLn j| j<-weave [' ','|',' ','|',' '] (interleave
(replicate 6 '-') [(interleave '|' i)| i<-g])]

interleave :: a->[a]->[a]
interleave x [] = []
interleave x [y] = [y]
interleave x (y:ys)= y:x:interleave x ys
weave :: a->[a]->[a]
weave x [] = [x]
weave x [y] = x:[y,x]
weave x (y:ys)= x:y:weave x ys

Prelude> putGrid [[' ','O','O'],['O','X','O'],['X','X','X']]
 | |
 |O|O
 | |
------
 | |
O|X|O
 | |
------
 | |
X|X|X
 | |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20180616/ae1cee57/attachment.html>


More information about the Beginners mailing list