sublists

1
2
3
4
5
6
7
8
9
10
11
12
13
14
sublist' [] = [[]]
sublist' (x:xs) = sublist' xs ++ map (x:) (sublist' xs)

compactByN :: Int -> [a] -> [[a]]
compactByN _ [] = [[]]
compactByN n list | length list == n = [list]
compactByN n list@(x:xs)= take n list : compactByN n xs

consecutive :: [Int] -> Bool
consecutive [_] = True
consecutive x = all (\[x,y] -> (x + 1 == y)) $ compactByN 2 x 

sublists :: [Int] -> [[Int]]
sublists = filter consecutive . filter (/= []) . sublist'