elm-community/list-split/1.0.2

NOTE: this package is not compatible with Elm 0.19.1

List.Split

Split lists into chunks

Splitters

chunksOfLeft : Int -> List a -> List (List a)

Split list into smaller lists of length k, starting from the left.

chunksOfLeft  3 [1..9] == [[1,2,3],[4,5,6],[7,8,9]]
chunksOfLeft  3 [1,2,3,4,5,6,7,8] == [[1,2,3],[4,5,6],[7,8]]
chunksOfLeft  3 [] == [[]]
chunksOfLeft  0 xs == [[]]
chunksOfLeft -1 xs == []
chunksOfRight : Int -> List a -> List (List a)

Split list into smaller lists of length k, starting from the right.

chunksOfRight  3 [1..9] == [[7,8,9],[4,5,6],[1,2,3]]
chunksOfRight  3 [1,2,3,4,5,6,7,8] == [[6,7,8],[3,4,5],[1,2]]
chunksOfRight  3 [] == [[]]
chunksOfRight  0 xs == [[]]
chunksOfRight -1 xs == []