Created
June 7, 2013 19:08
-
-
Save vishesh/5731608 to your computer and use it in GitHub Desktop.
Scheme: Subsets of given list
This file contains hidden or 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 (subsets s) | |
| (if (null? s) | |
| (list null) | |
| (let ((rest (subsets (cdr s)))) | |
| (append rest (map (lambda (x) | |
| (cons (car s) x)) | |
| rest))))) | |
| (subsets '(1 2 3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks mate!