combn   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/contrib/word_count.xtm

Implementation

(define combn
  (lambda (lst n)
    (println 'lst: lst 'n: n)
    (cond ((< n 1) '())
          ((= n 1) (map list lst))
          ((null? lst) '())
          (else (append (map (lambda (subset) (cons (car lst) subset))
                             (combn (cdr lst) (- 1 n)))
                        (combn (cdr lst) n))))))


Back to Index