How (Not?) to Use Python’s List Comprehensions
If I were to start it in Common Lisp, I&#x27;d probably do something like this. Next steps might be to make normal variable declarations automatic by scanning guard expressions (which would prevent unwittingly mentioning a variable too early); and depending on the intended usage, maybe permit infix math via the infix-math package.<p><pre><code>    (defpackage solver (:use :cl :iterate) (:shadow pi))
    (in-package :solver)

    (defmacro defsolver (name default constraints result)
      (flet ((normal-var (var)      `(iter (for ,var ,@(rest default))))
             (custom-var (var spec) `(iter (for ,var in ,spec)))
             (guard (expr)          `(when ,expr))
             (solved ()             `(return-from ,name ,result)))
        (macrolet ((yield (form) `(append ,form (list (constraint (rest cs))))))
          (labels ((constraint (cs &amp;aux (c (first cs)))
                     (cond ((null cs)           nil)
    		           ((eq c :solved)      (solved))
    		           ((symbolp c)         (yield (normal-var c)))
    		           ((eq (first c) &#x27;for) (yield (custom-var (second c) (third c))))
    		           (t                   (yield (guard c))))))
            `(defun ,name () ,(constraint `(,@constraints :solved)))))))

    (defsolver result
      (:default from 1 to 26)
      (th
       o
       r
       (= (+ (* 2 (expt th 2)) (expt o 2) (expt r 2)) 1000)
       s
       z
       (= (+ (* (expt th 2) (expt z 2) (- s z)) (expt s 2)) 7225)
       g
       d
       xi
       (= (+ (expt (1- g) 2) (expt d 2) (expt xi 2) (- xi)) 600)
       (for (et i) `((,(- xi 7) ,(- xi 11)) (,(- xi 11) ,(- xi 7))
                     (,(+ xi 7) ,(+ xi 11)) (,(+ xi 11) ,(+ xi 7))))
       (and (&lt; 0 et) (&lt;= et 26) (&lt; 0 i) (&lt;= i 26))
       (for (a mu) &#x27;((4 1) (2 2) (1 4)))
       pi
       (= (* 4 g) (* a (+ a pi)))
       b
       n
       (= (+ (expt b 3) (expt z 3) (expt n 3) (expt o 9)) 1997)
       (for k &#x27;(3 4))
       e
       (= (+ (expt (&#x2F; a k) 2) (expt (&#x2F; b n) 2) (expt (&#x2F; d xi) 2)
    	 (expt (&#x2F; e pi) 2) (expt (&#x2F; et mu) 2) (expt (&#x2F; i s) 2)) 6))
      (list a b g d e z et th i k th mu n xi o pi r s))

    SOLVER&gt; (time (result))
    Evaluation took:
      0.010 seconds of real time
      0.012000 seconds of total run time (0.012000 user, 0.000000 system)
      120.00% CPU
      23,160,723 processor cycles
      851,968 bytes consed
    
    (4 9 19 12 15 3 1 20 5 4 20 1 9 12 2 15 14 5)
</code></pre>
Edit: formatting, simplification<p>The b, n, k, e definitions are reordered better as in @eutectic&#x27;s haskell example.