I have a function, that clusters the consecutive numbers in a list, but I am getting an error stating
Non exhaustive patterns
causing the last set of consecutive integers not to print.
consecutive (w:v:zs) = help (w:v:zs) []
where
help [] buffer = []
help (w:v:zs) buffer | (w+1 /= v) = (reverse (w:buffer)) : (help (v:zs) ([]))
| otherwise = (help (v:zs) (w:buffer))
Ok, one module loaded.
*HW1> consecutive [1,2,3,5,6,7,8,9,2,3,11,12]
[[1,2,3],[5,6,7,8,9],[2,3]*** Exception: HW1.hs:(108,36)-(110,94): Non-exhaustive patterns in function help