Netlogo:如何使用 with、if 语句或 else 添加一些条件?

Netlogo: How can I add some conditions by using the with, if statement or else?

我想统计停在路上的乌龟的数量,我想把那个X坐标信息作为队列长度。以下是示例程序。

ask turtles with [ not right-end ] ;a flag "right-end" to the red turtle for differentiation to the other blue turtles
[
  ask turtles with [ speed = 0 ] ;the speed is 0 means stopped
  [
    set top max-one-of turtles [who] ;get a turtle with biggest id
    set topx [xcor] of top
    set L count turtles with [xcor > topx] ; L is the queue length of Little's Law
  ]
]

我无法准确理解你想要做什么,但我认为它是这样的:

to-report countRightmost ;global context
  let ts (turtles with [speed = 0 and not right-end] )
  let top max-one-of turtles [who]
  let topx [xcor] of top
  report count ts with [xcor > topx]
end