[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Gcl-devel] Can't Pretty-print?

**From**: |
Martin Rubey |

**Subject**: |
[Gcl-devel] Can't Pretty-print? |

**Date**: |
Thu, 14 Feb 2002 12:04:26 +0100 (MEZ) |

The following produces an obscure error message in gcl 2.5.0
(not so in clisp)
(or is the code bad?)
(cartesian (list '((a b) (c)) '(((a) (b)) ((c) (d)))))
(defun cartesian (sets)
"Returns the Cartesian product of a list of sets
Example:
(CARTESIAN '((A B) (C D) (E F)))
;=> ((B C F) (B C E) (B D F) (B D E) (A C F) (A C E) (A D F) (A D
E))
Non-recursive version.
"
(let ((cartesian (list nil)))
(dolist (set (reverse sets)) ; reverse is only for esthetics
(let ((new-cartesian nil))
(dolist (elmt set)
(dolist (cart cartesian)
(push (cons elmt cart) new-cartesian)))
(setf cartesian new-cartesian)))
cartesian))

**[Gcl-devel] Can't Pretty-print?**,
*Martin Rubey* **<=**