/usr/share/zenlisp/combine.l is in zenlisp 2013.11.22-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | ; zenlisp example program
; By Nils M Holm, 1998-2007
; See the file LICENSE for conditions of use.
; Create combinations of a set with (COMBINE*)
; and without (COMBINE) repetition:
; (combine '#2 '(a b c)) => '(#ab #ac #bc)
; (combine* '#2 '(a b c)) => '(#aa #ab #ac #bb #bc #cc)
(require '~nmath)
(define (combine3 n set rest)
(letrec
((tails-of
(lambda (set)
(cond ((null set) ())
(t (cons set (tails-of (cdr set)))))))
(combinations
(lambda (n set)
(cond
((zero n) ())
((one n) (map list set))
(t (apply
append
(map (lambda (tail)
(map (lambda (sub)
(cons (car tail) sub))
(combinations (- n '#1) (rest tail))))
(tails-of set))))))))
(combinations n set)))
(define (combine n set)
(combine3 n set cdr))
(define (combine* n set)
(combine3 n set id))
|