2

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.

Steven Doggart
  • 43,358
  • 8
  • 68
  • 105
user5070
  • 21
  • 3

1 Answers1

2

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.

Steven Doggart
  • 43,358
  • 8
  • 68
  • 105