Haskell : getting missing range in list

–gets range between two consecutive elements of List
missingElements (x:x1:xs) | x1> (succ x) = [(succ x)..(pred x1)]: missingElements (x1:xs)
                        | otherwise = missingElements(x1:xs)
missingElements _ =[]

–sample o/p
— missingElements [‘a’,’e’,’b’,’c’,’f’]
–[“bcd”,”de”]

–missingElements [1,5,3,4,5,8]
–[[2,3,4],[6,7]]

–Post is for Little Ryan and his invisible dog

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s