How to create a list containing numbers from 1 to a given number in NetLogo?

Does anyone know how to create a list containing numbers from 1 to a given number in NetLogo? Looks like [1 2 ... this number] thanks!

+4
source share
1 answer

NetLogo has a primitive for what is called n-values. Very simple:

n-values 10 [ ? + 1 ]

will give you a list:

[1 2 3 4 5 6 7 8 9 10]

But there are many other neat things you can do with help n-values. You should take a look at the documentation .

Update:

NetLogo 6.0 now has a rangeprimitive that can be used for the same purpose:

observer> print (range 1 11)
[1 2 3 4 5 6 7 8 9 10]
+5
source

Source: https://habr.com/ru/post/1545593/


All Articles