Created
January 30, 2020 03:35
-
-
Save awave1/cc03249d6686d5bc23f16f06a2415e00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group :: (a -> a -> Bool) -> [a] -> [[a]] | |
group _ [] = [] | |
group _ [el] = [[el]] | |
group predicate (a : b : list) | |
| predicate a b = append a (group predicate (b : list)) | |
| otherwise = [a] : group predicate (b : list) | |
where append el (a : list) = (el : a) : list | |
nbr :: Int -> Int -> Bool | |
nbr num1 num2 = abs (num1 - num2) <= 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment