Created
October 26, 2008 00:25
-
-
Save KirinDave/19820 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (permute terms) | |
(permute-help terms (length terms))) | |
(define (permute-help terms descent) | |
(cond | |
((= (length terms) 1) (list terms)) | |
((< descent 1) (list)) | |
(else (append | |
(map (lambda (x) (cons (car terms) x)) (permute-help (cdr terms) (length (cdr terms)))) | |
(permute-help (append (cdr terms) (list (car terms))) (- descent 1)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment