
26 Mar
2018
26 Mar
'18
6:26 p.m.
To be more explicit:
λ> :m +Data.List (groupBy) λ> :m +Data.Function (on) λ> l = [1,2, 3, 4, 6, 7, 9, 10] λ> map (map snd) $ groupBy ((==) `on` snd) $ zip l (zipWith (-) l [1..]) [[0,0,0,0],[1,1],[2,2]]
I imagine that you mean fst instead of snd in order to produce the right output :) How can I check if this code produce list copies and is efficient with big lists ? thanks Frederic