Skip to content

Instantly share code, notes, and snippets.

@chakrit
Created June 11, 2019 15:28
Show Gist options
  • Save chakrit/c7a71eaf25f187068095f6046b46edc3 to your computer and use it in GitHub Desktop.
Save chakrit/c7a71eaf25f187068095f6046b46edc3 to your computer and use it in GitHub Desktop.
Elm groupOf function
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