[toronto-lisp] access to previous value in loop

8 Jan
2010
8 Jan
'10
5:44 a.m.
Abram--I stumbled upon equals-then assignment clauses when reading up on something else I'd needed to do with loop: (loop repeat 5 for prev = 0 then i for i = 17 then (1+ i) collect (cons i prev)) ; => ((17 . 0) (18 . 17) (19 . 18) (20 . 19) (21 . 20)) note: these clauses are evaluated in order so this example wouldn't work if the equals-then clause for i appeared before the one for prev. if the prev clause comes first, it can take the value of i from the previous iteration before it's updated. Justin
5600
Age (days ago)
5600
Last active (days ago)
0 comments
1 participants
participants (1)
-
Justin Giancola