What is an example of a recursive function to compute all possible combinations of lists? For example, (combine (list 1 2 3) (list 1 2)) should return \'
(combine (list 1 2 3) (list 1 2))
\'
Here's my solution. Requires SRFIs 1 and 26 to be available.
(define (cartesian-product first . rest) (define (iter l result) (define (prepend-all x) (map (cut cons <> x) l)) (concatenate (map prepend-all result))) (map reverse (fold iter (map list first) rest)))