Talk:Blow your mind
From HaskellWiki
m |
(Mind-blowing considered harmful) |
||
| Line 7: | Line 7: | ||
Is there a better name for this page? —[[User:Ashley Y|Ashley Y]] 00:55, 2 March 2006 (UTC) | Is there a better name for this page? —[[User:Ashley Y|Ashley Y]] 00:55, 2 March 2006 (UTC) | ||
| + | i completely agree, the name pretty much sucks. but what i really wanted, was to compile a collection of "idioms" that would enlarge the readers perception of what is possible in Haskell and how to go about it. so, i'll have to find a name that reflects this plan. —--[[User:JohannesAhlmann|Johannes Ahlmann]] 14:13, 2 March 2006 (UTC) | ||
| - | + | == Elegance before pyrotechnics == | |
| + | |||
| + | The polynomial algorithms are indeed mind-blowing, like the excess of Mardi Gras. They smuggle in subscripts, which (blessedly) Haskell usually banishes, disguised in a pyrotechnic display of abstraction, replication, concatenation, composition and enumeration. | ||
| + | |||
| + | Gilles Kahn invented a much more docile and beautiful way to do these things with true Haskell elegance long before Haskell: | ||
| + | |||
| + | instance Num a => [a] where | ||
| + | fs + [] = fs | ||
| + | [] + gs = gs | ||
| + | (f:fs) + (g:gs) = f+g : fs+gs | ||
| + | |||
| + | (f:fs) * (g:gs) = f*g : [f]*gs + fs*(g:gs) | ||
| + | _ * _ = [] | ||
| + | |||
| + | Unlike the mind-blowing version, this code works on infinite series as well as polynomials. —[[User:dougm:Doug McIlroy]] 20 December 2006 | ||
Revision as of 14:37, 20 December 2006
1 Could these be on their own page?
Hi Johannes - Great stuff on your page. Have you thought about making it an actual page in the WIKI? You could then add[[Category:Idioms]]and more people would find it. BrettGiles 16:19, 1 March 2006 (UTC)
2 Name?
Is there a better name for this page? —Ashley Y 00:55, 2 March 2006 (UTC)
i completely agree, the name pretty much sucks. but what i really wanted, was to compile a collection of "idioms" that would enlarge the readers perception of what is possible in Haskell and how to go about it. so, i'll have to find a name that reflects this plan. —--Johannes Ahlmann 14:13, 2 March 2006 (UTC)
3 Elegance before pyrotechnics
The polynomial algorithms are indeed mind-blowing, like the excess of Mardi Gras. They smuggle in subscripts, which (blessedly) Haskell usually banishes, disguised in a pyrotechnic display of abstraction, replication, concatenation, composition and enumeration.
Gilles Kahn invented a much more docile and beautiful way to do these things with true Haskell elegance long before Haskell:
instance Num a => [a] where fs + [] = fs [] + gs = gs (f:fs) + (g:gs) = f+g : fs+gs
(f:fs) * (g:gs) = f*g : [f]*gs + fs*(g:gs) _ * _ = []
Unlike the mind-blowing version, this code works on infinite series as well as polynomials. —User:dougm:Doug McIlroy 20 December 2006
