CreatingRhythms-0.0.27.0
Copyright(c) Eric Bailey 2024-2025
LicenseMIT
Maintainereric@ericb.me
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Rhythm.Partitions

Description

Integer partitions, i.e., representations of integers as a sum of positive integers where the order of the summands is not significant.

Synopsis

Documentation

partitions :: Int -> [Partition] Source #

Partitions of a given number.

>>> partitions 3
[Partition [1,1,1],Partition [2,1],Partition [3]]

partitionsAllowed :: Foldable t => t Int -> Int -> [Partition] Source #

Partitions with allowed parts.

>>> partitionsAllowed [1,2,3] 4
[Partition [1,1,1,1],Partition [2,1,1],Partition [2,2],Partition [3,1]]

partitionsLength :: Int -> Int -> [Partition] Source #

Partitions of a given length.

>>> partitionsLength 3 7
[Partition [3,2,2],Partition [3,3,1],Partition [4,2,1],Partition [5,1,1]]

partitionsLengthAllowed :: Foldable t => Int -> t Int -> Int -> [Partition] Source #

Partitions of a given length with allowed parts.

>>> partitionsLengthAllowed 2 [1,2,3] 4
[Partition [2,2],Partition [3,1]]