Skip to content

Commit

Permalink
Fix wrong LOOP form: it contained FOR and UNTIL statements mixed in a…
Browse files Browse the repository at this point in the history
…n invalid and undefined way, as per the ANSI standard: http://www.lispworks.com/documentation/HyperSpec/Body/06_aba.htm "The iteration control clauses for, as, and repeat must precede any other loop clauses, except initially, with, and named, since they establish variable bindings."
  • Loading branch information
juanjosegarciaripoll authored and froydnj committed Sep 29, 2012
1 parent 6c70e43 commit fc2ac2e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/math.lisp
Expand Up @@ -8,16 +8,16 @@ denominator."
(type integer a b))
(assert (and (>= a 0)
(>= b 0)))
(loop
for c = a then (- d (* q c))
and d = b then c
for u_c = 1 then (- u_d (* q u_c))
and v_c = 0 then (- v_d (* q v_c))
and u_d = 0 then u_c
and v_d = 1 then v_c
until (= c 0)
for q = (floor d c)
finally (return (values d u_d v_d))))
(do ((q 0)
(c a (- d (* q c)))
(d b c)
(u_c 1 (- u_d (* q u_c)))
(v_c 0 (- v_d (* q v_c)))
(u_d 0 u_c)
(v_d 1 v_c))
((= c 0)
(values d u_d v_d))
(setq q (floor d c))))

(defconst +small-primes+
(make-array 269
Expand Down

0 comments on commit fc2ac2e

Please sign in to comment.