Home / Logic / Truth table / Implementation / Function scheme/boolean-product
Implement
(define (boolean-product length)
"Return a list of all Boolean sequences of LENGTH."
(let more-rows ((row (- (expt 2 length) 1)))
(if (< row 0) (list)
(cons (let more-columns ((column (- length 1)))
(if (< column 0) (list)
(cons (even? (quotient row (expt 2 column)))
(more-columns (- column 1)))))
(more-rows (- row 1))))))