Rudy’s OBTF Rudolf Adamkovič

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))))))

© 2025 Rudolf Adamkovič under GNU General Public License (GPL) version 3 or later.
Made with Emacs and secret alien technologies of yesteryear.