aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: ac90b41f1d511b89795c6fe328166d1f721e9f4b (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# 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](https://jeromekelleher.net/category/combinatorics.html).

## 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

```scheme
(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:

```shell
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](./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](https://jeromekelleher.net/downloads/k06.pdf)
- Kelleher, J. (2014, May 26). *Generating Integer Partitions*. [https://jeromekelleher.net/generating-integer-partitions.html](https://jeromekelleher.net/generating-integer-partitions.html)

## Copyright

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