Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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