You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
350 B

; Exercise 2.32
(define nil ())
(display "Exercise 2.32 (subsets)")
(define (subsets s)
(if (null? s)
(list nil)
(let ((rest (subsets (cdr s)))
(x (car s)))
(append rest (map (lambda (r) (cons x r)) rest)))))
(define l (list 1 2 3))
(display "Subsets of ")
(display l)
(display (subsets l))