This page is part of the web mail archives of SRFI 113 from before July 7th, 2015. The new archives for SRFI 113 contain all messages, not just those from before July 7th, 2015.
Kevin Wortman scripsit: > (define (cartesian . sets) > (fold-right (lambda (set tuples) > (append-map! (lambda (element) > (map (cute cons element <>) tuples)) > set)) > '(()) > sets)) This is the same algo that I worked out walking to work today, except that I reversed "sets" in advance (it's safe to use reverse!) and did a left fold, because left folds are tail-recursive in eager languages. -- John Cowan http://www.ccil.org/~cowan cowan@xxxxxxxx You know, you haven't stopped talking since I came here. You must have been vaccinated with a phonograph needle. --Rufus T. Firefly