Skip to content

Instantly share code, notes, and snippets.

@vishesh
Created June 7, 2013 19:08
Show Gist options
  • Select an option

  • Save vishesh/5731608 to your computer and use it in GitHub Desktop.

Select an option

Save vishesh/5731608 to your computer and use it in GitHub Desktop.
Scheme: Subsets of given list
(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))
@danhvo11012

Copy link
Copy Markdown

Thanks mate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment