[Haskell-cafe] List of numbers to list of ranges

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Fri Dec 24 00:33:44 CET 2010


This one looks somewhat symmetrical:

 f xs =
       let xys = filter ( \ (x,y) -> y - x > 1 )
               $ zip xs ( tail xs )
       in  zip ( [ head xs ] ++ map snd xys )
               ( map fst xys ++ [ last xs ] )






More information about the Haskell-Cafe mailing list