This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

List with unexpected values!?

4 posts · 2044 views

Why is my gennum function attaching it's return value l? I've commented everything inside gennum, just left a return value.
(loop for y below m do
(loop for x below n do
(when(zerop(coord x y table))
(print l)
(unless(setf v([b]gennum[/b] x y [b]l[/b] out))
(return-from alpha nil)))))

Re: List with unexpected values!?

xernobyl wrote:Why is my gennum function attaching it's return value l? I've commented everything inside gennum, just left a return value.
That code is very confusingly indented, and hence unreadable. Please use standard indentation rules. It is also apparently a fragment with missing context. Since, as it stands, it uses several identifiers as global variables, it is impossible to say anything about its behaviour. In any case, using the return value of SETF as a condition seems weird. And I don't even understand your question, "attaching its return value" to what?

Re: List with unexpected values!?

Trying to simplify the problem...

This:
(print l)
(loop for y below m do
	(loop for x below n do
		(when(zerop(coord x y table))
			(setf v (gennum x y l out))
			(put v x y out)
			(push v l)))
			(print v)
			(print l))
Outputs:
(1 8 2 9 6)
7
(7 8 2 0 9 0 6 NIL NIL NIL)
3
(3 0 1 NIL 2 0 NIL 7 6 NIL)
7
(7 NIL NIL NIL NIL 0 4 NIL 8 2)
Why is my list l getting values other than those in v (the nils and 0s)?
Why doesn't it result in this:
(1 8 2 9 6)
7
(7 1 8 2 9 6)
3
(3 7 1 8 2 9 6)
7
(7 7 1 8 2 9 6)
???

Re: List with unexpected values!?

xernobyl wrote:Trying to simplify the problem...
That code on my system results in:
The variable L is unbound.
   [Condition of type UNBOUND-VARIABLE]
on the very first line, and so is useless.

My guess would be that you are mutating constant literals somewhere inside those operators you didn't show the source for. Remember that QUOTE (abbreviated with quote symbol syntax) is not the same as LIST. Remember that you have to bind variables before setting them (that 'v' looks suspicious).