Hey,
i need a function that gives me the first position of a T in the *world*- array.
The *world*-array looks like that.
#2A((W G G G G R W T G G W G G G)
(W G G T G G W G G G W G G G)
(W W W G W W W W T W W W W G)
(G G G G G T G G G G G G G G)
(W W W G W W W W W W T W W W)
(G T W G W G G G W G G G W W)
(G G W G W G G G W G G G W W)
(G G G G G G G G W T T G W W)
(G G W G W G G G W W W W W W)
(W W W G W W W W W W W W W W)
(G T W G W G G G W W W W W W)
(G G G G W G G G W W W W W W)
(G G W G G G T G W W W W W W))
My function looks like this. My function always return NIL and i don't no why it should return (0 7).
(defun get-treasure-coordinate ()
(loop for x from 0 to 12 do
(loop for y from 0 to 13 when(eql 'T (aref *world* x y))
collect (list x y)
)
)
)
Loop 2D-Array
Forum rules
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Please respect your teacher's guidelines. Homework is a learning tool. If we just post answers, we aren't actually helping. When you post questions, be sure to show what you have tried or what you don't understand.
Re: Loop 2D-Array
You are close. How does 'loop' return a value?
Consider:
> (loop for x from 1 to 3 do x)
NIL
> (loop for x from 1 to 3 collect x)
(list 1 2 3)
Then look again at your two loops ... if you change one word you will get some results back, which will still need some tidying up.
Consider:
> (loop for x from 1 to 3 do x)
NIL
> (loop for x from 1 to 3 collect x)
(list 1 2 3)
Then look again at your two loops ... if you change one word you will get some results back, which will still need some tidying up.