| Paste number 52642: | cartesian-product |
| Pasted by: | faxathisia |
| When: | 4 years, 1 month ago |
| Share: | Tweet this! | http://paste.lisp.org/+14MA |
| Channel: | #lispcafe |
| Paste contents: |
(defun cartesian-product (&rest lists)
(if (endp lists) '(())
(apply #'append
(mapcar #'(lambda (head) (mapcar #'(lambda (tail) (cons head tail))
(apply #'cartesian-product (rest lists))))
(first lists)))))Annotations for this paste:
| Annotation number 1: | cartesian-product car/cdr |
| Pasted by: | faxathisia |
| When: | 4 years, 1 month ago |
| Share: | Tweet this! | http://paste.lisp.org/+14MA/1 |
| Paste contents: |
(defun cartesian-product (list &rest lists)
(if (endp lists) (mapcar #'list list)
(apply #'append
(mapcar #'(lambda (head) (mapcar #'(lambda (tail) (cons head tail))
(apply #'cartesian-product lists)))
list))))