AccelAsc for R7RS
This library provides an implementation of the algorithm called accel_asc
by Jerome Kelleher, which generates integer partitions in R7RS.
For more details about accel_asc
, please refer to Jerome Kelleher's website.
Requirements
- R7RS-small
(scheme generator)
or SRFI-158
Usage
Library (integer-partition accel-asc)
(accel-asc n) → <generator>
Returns a generator that produces a vector of integers representing integer partitions for the given value of integer n
.
Examples
(import (scheme base)
(srfi 158)
(integer-partition accel-asc))
(generator-for-each (lambda (v) (display v) (newline))
(accel-asc 8))
Output:
#(1 1 1 1 1 1 1 1)
#(1 1 1 1 1 1 2)
#(1 1 1 1 1 3)
#(1 1 1 1 2 2)
#(1 1 1 1 4)
#(1 1 1 2 3)
#(1 1 1 5)
#(1 1 2 2 2)
#(1 1 2 4)
#(1 1 3 3)
#(1 1 6)
#(1 2 2 3)
#(1 2 5)
#(1 3 4)
#(1 7)
#(2 2 2 2)
#(2 2 4)
#(2 3 3)
#(2 6)
#(3 5)
#(4 4)
#(8)
Source code
Use git command
To clone the repository r7rs-accel-asc
, you can use the following git command:
git clone https://git.tojo.tokyo/r7rs-accel-asc.git
After cloning, you can explore the code and integrate it into your R7RS projects.
Changelog
See the CHANGELOG.md file.
License
This library is released under the Apache License Version 2.0. See the LICENSE file for more details.
References
- Kelleher, J. (2006). Encoding partitions as ascending compositions [Doctoral dissertation, University College Cork]. https://jeromekelleher.net/downloads/k06.pdf
- Kelleher, J. (2014, May 26). Generating Integer Partitions. https://jeromekelleher.net/generating-integer-partitions.html
Copyright
Copyright (c) 2024 Masaya Tojo masaya@tojo.tokyo