diff options
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))))))) |