
24 Mar
2009
24 Mar
'09
11:48 p.m.
Code like that is why I love Haskell, while I haven't written a Haskell program in years it is still a joy to read (much more so than the pretty good zipWith version). In reference to later comments: if you don't know Monads, you don't know Haskell; that goes double for high order functions. So really the only place where this code may be inappropriate is in a beginner tutorial (unless you are trying to show why they need to learn more!). C Miguel Mitrofanov wrote:
takeList ns xs = evalState (mapM (State . splitAt) ns) xs
or even
takeList = evalState . map (State . splitAt)