Reputation: 121
I am using Logo and I have certain problems while iterating through list. What is the problem with the line.
if count :L = 0 [stop]
The :L is a list. So, I would like to test the length of list and stop after the list is empty.
Upvotes: 2
Views: 374
Reputation: 43743
You need to wrap the count command in parentheses so that it is evaluated first:
if (count :L) = 0 [stop]
It also wouldn't hurt to add additional parentheses around the entire test and also add the empty brackets for the else clause (if required by your logo interpreter):
if ((count :L) = 0) [stop] []
Bear in mind, stop
is used to exit a procedure. If all you want to do is exit out of a loop, you may want to look at other loop structures like a for
, while
or until
loop.
Upvotes: 2