@hackage list-grouping0.1

Functions for grouping a list into sublists

  • Categories

    • License

      BSD-3-Clause

    • Maintainer

      Brandon Simmons <brandon.m.simmons@gmail.com>

    • Versions

      • 0.1.1 Sun, 13 Feb 2011
      • 0.1 Thu, 13 Aug 2009

    Functions for grouping a list into sublists based on predicate or integer offsets.

    Grouping a list based on integer offsets:

    splitEvery 3 [1..10]  ==  [[1,2,3],[4,5,6],[7,8,9],[10]]
    splitWith [1,3,1,3] [1..10]  ==  [[1],[2,3,4],[5],[6,7,8],[9,10]]
    splitWithDrop [1,3,1,3] [1..10]  ==  [[1],[2,3,4],[5],[6,7,8]]

    Grouping based on a predicate:

    breakBefore odd [2..9]  ==  [[2],[3,4],[5,6],[7,8],[9]]
    breakAfter odd [2..9]  ==  [[2,3],[4,5],[6,7],[8,9]]
    breakDrop odd [0,0,0,1,0,1,1,0,0]  ==  [[0,0,0],[0],[0,0]]

    Please send me any comments, requests or bug reports