[ prog / sol / mona ]

prog


Cartesian product.

11 2021-10-02 21:04
(use-modules (srfi srfi-1))

(define (cartesian-product . sets)
  (cond
   ((null? sets) '(()))
   (else
    (let ((rest (apply cartesian-product (cdr sets))))
      (append-map
       (lambda (x)
         (map (lambda (r) (cons x r)) rest))
          (car sets))))))
12


VIP:

do not edit these