Kevin Wortman scripsit:
This is the same algo that I worked out walking to work today, except
> (define (cartesian . sets)
> (fold-right (lambda (set tuples)
> (append-map! (lambda (element)
> (map (cute cons element <>) tuples))
> set))
> '(())
> sets))
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.
You know, you haven't stopped talking since I came here. You must
have been vaccinated with a phonograph needle.
--Rufus T. Firefly