
24 Apr
2016
24 Apr
'16
10:41 a.m.
consume f g a = foldl f a . chunk g chunk g = unfoldr (fmap g . (\xs -> if null xs then Nothing else Just xs))
Wow, nice. I figured there must be a better way to express that.
gatherRoots = chunk (partition (compare `on` root))
That doesn't typecheck. I think you meant
gatherRoots = chunk $ \ l@(x:_) -> partition (\y -> root x == root y) l
P.S. You would be correct in claiming that this rewrite is too distant from the original to be of use. My apologies if this is the case.
No, this helps a lot, thanks! Reading pro Haskell like this helps me improve. It's way more advanced than what I could possibly come up with though. I'm still working my way through it. Daniel