Created
June 11, 2019 15:28
-
-
Save chakrit/c7a71eaf25f187068095f6046b46edc3 to your computer and use it in GitHub Desktop.
Elm groupOf function
This file contains 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
groupOf : Int -> List a -> List (List a) | |
groupOf count list = | |
let | |
len = | |
List.length list | |
in | |
if len >= count then | |
List.take count list :: (groupOf count <| List.drop count list) | |
else if len > 0 then | |
[ list ] | |
else | |
-- len <= 0 | |
[] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment