diff options
author | Christopher Baines <mail@cbaines.net> | 2016-05-16 22:20:12 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2016-09-04 23:05:14 +0100 |
commit | 86de22b526313a68e5c8bb8a361d5904c30d8b51 (patch) | |
tree | c3307b2e032ac87f8d5c2ff79e57eff692cecf2b /pypi/utils.scm | |
download | guix-pypi-utils-86de22b526313a68e5c8bb8a361d5904c30d8b51.tar guix-pypi-utils-86de22b526313a68e5c8bb8a361d5904c30d8b51.tar.gz |
Initial commit
Diffstat (limited to 'pypi/utils.scm')
-rw-r--r-- | pypi/utils.scm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pypi/utils.scm b/pypi/utils.scm new file mode 100644 index 0000000..88ec879 --- /dev/null +++ b/pypi/utils.scm @@ -0,0 +1,24 @@ +(define-module (pypi utils) + #:use-module (ice-9 match) + #:use-module (srfi srfi-69) + #:use-module (guix packages) + #:export (all-combinations)) + +; Combinatorics + +(define (combinations lst len) + (cond ((= len 0) + '(())) + ((null? lst) + '()) + (else (append (map (lambda (rest) (cons (car lst) rest)) + (combinations (cdr lst) (- len 1))) + (combinations (cdr lst) len))))) + +(define (all-combinations lst) + (apply + append + (map + (lambda (len) + (combinations lst len)) + (cdr (iota (+ 1 (length lst))))))) |