Jump to content

Cartesian product of two or more lists: Difference between revisions

Line 441:
 
=={{header|Common Lisp}}==
<lang lisp>(defun n-cartesian-product (l)
"Compute the n-cartesian product of a list of sets represented as list with a mixed recursive-iterative approach.
Algorithm:
Line 450:
(list nil)
(loop for x in (car l)
nconc (loop for y in (n-cartesian-product (cdr l))
collect (cons x y)))))</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.