group :: Ord a => [(a, [b])] -> [(a, [b])]
I want to look at all the pairs that have the same fst, and combine them by adding the entire list bs together, where they have the same a and drop the unprotected pair and so on ...
Reached:
group ((s, ls):(s', ls'):ps) =
if s == s'
then group ((s, ls++ls'):ps)
else (s, ls) : group ((s', ls'):ps)
group p = p
but obviously this is not going to cut him, because he does not group everything.
Edit: Example
[("a", as),("c", cs), ("c", cs3), ("b", bs),("c", cs2), ("b", bs2)]
displays
[("a", as),("c", cs++cs2++cs3),("b", bs++bs2)]
source
share