aboutsummaryrefslogtreecommitdiff

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)

License

This library is released under the Apache License Version 2.0. See the LICENSE file for more details.

References

Copyright (c) 2024 Masaya Tojo masaya@tojo.tokyo