The linked paper appears to show the right style. This appears to satisfy the conditions, however:
inTwain as = let (x,y,_) = foldr (\a (r,s,t) -> case (t) of {b:(b':bs) -> (r,a:s,bs); _ -> (a:r,s,t)}) ([],[],as) as in (x,y) In the case of a list of odd length, the first half is given the extra element. On Thu, Jun 4, 2009 at 8:22 AM, Martijn van Steenbergen < mart...@van.steenbergen.nl> wrote: > 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? > > Is there a general way to tell if a problem can be expressed as a fold? > > Thank you, > > Martijn. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe >
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe