
5 Jun
2009
5 Jun
'09
11:38 a.m.
Martijn van Steenbergen
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