
4 Jun
2009
4 Jun
'09
2:33 p.m.
On Thu, Jun 4, 2009 at 4:22 PM, Martijn van Steenbergen
Bonjour café,
A small puzzle:
Consider the function inTwain that splits a list of even length evenly into two sublists:
inTwain "Hello world!" ("Hello ","world!")
Is it possible to implement inTwain such that the recursion is done by one of the standard list folds?
I don't think it is without a length before at least. On the other hand if your specification is just "splits a list of even length evenly into two sublists", you can contrive something with a simple foldr : inTwain = foldr (\x ~(xs,ys) -> (ys, x:xs)) ([],[]) -- Jedaï