Hi all,
How nice to see that my mail from July 11 generated so many different
diagonalization functions without using integers!
I saw Wolfram's reply with his interesting programming challenge but I
went on a holiday straight after that, so I could not participate in the
flood of messages that followed.
Now I am back, I do not want to withhold the solution I came up with.
Here it is (*):
as // bs = diag [] [ [ (a,b) | a <- as] | b <- bs ]
diag current [] = diag [] current
diag current (new : pending) = heads ++ diag (new : tails) pending
where
(heads,tails) = unzip [ (c,cs) | (c:cs) <- current ]
I thought it was short and sweet :-)
I think the (//) and (&) operators are very useful and are a very good
alternative to the special syntax that Miranda (tm) and Clean offer.
Shouldn't they be included in some standard module?
Regards,
Koen.
(*) Thanks to Arjan van IJzendoorn for his help in choosing variable
names.
--
Koen Claessen http://www.cs.chalmers.se/~koen
phone:+46-31-772 5424 e-mail:[EMAIL PROTECTED]
-----------------------------------------------------
Chalmers University of Technology, Gothenburg, Sweden