On Thu, Dec 23, 2010 at 10:57:43PM +0530, C K Kashyap wrote: > Here's my attempt to convert a list of integers to a list of range tuples - > > Given [1,2,3,6,8,9,10], I need [(1,3),(6,6),8,10)]
import Data.Function import Data.List ranges ns = [(head gp, last gp) | gp <- map (map fst) $ groupBy ((==) `on` snd) $ zip ns (zipWith (-) ns [1..])] _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe