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

Data.Rhythm.Binary.RuskeySavageWang

Description

Binary necklaces, internally encoded as numbers.

References

Synopsis

Documentation

necklaces :: Int -> [[Int]] Source #

All binary necklaces of a given length.

>>> necklaces 4
[[1,1,1,1],[1,1,1,0],[1,1,0,0],[1,0,1,0],[1,0,0,0],[0,0,0,0]]

necklaces' :: (Integral a, Bits a) => Int -> Tree a Source #

All binary necklaces of a given length, encoded as numbers.

\[ \begin{align*} \sigma(x_1 ... x_n) &= x_2 ... x_n x_1 \\ \tau(x_1 ... x_{n-1}) &= x_1 ... x_{n-1}\overline{x_n} \end{align*} \]

Generate the tree of binary necklaces of length \(n\), starting with \(x = 0^n\) as root, where children of \(x\) are the necklaces of the form \(\tau\sigma^j(x)\) for \(1 \le j \le n -1\).

>>> flatten (necklaces' 4)
[0,1,3,7,15,5]

nodesToNecklaces :: Int -> [Integer] -> [[Int]] Source #

Convert a list of nodes to binary necklaces of a given length.

>>> nodesToNecklaces 4 [3,5]
[[1,1,0,0],[1,0,1,0]]