Martijn van Steenbergen <[email protected]> writes:

>>> inTwain = foldr (\x (ls, rs) -> if length ls == length rs then (x:ls, rs) 
>>> else (x:(init ls), (last ls):rs)) ([], [])

> But this uses length and init and last all of which are recursive
> functions. I consider that cheating: only foldr may do the recursion.

inTwain = foldr (\x (ls, rs) -> if foldr (const (+1)) 0 ls = ... ?

:-)

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to