Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NetLogo - Setting a parameter to an Integer

Setting a function parameter to an integer in NetLogo

After exhausting the Documentation for NetLogo online, I couldn't find a solution to set a parameter (lets call it r), to an integer in the function declaration.

In python it is as simple as WTMC(n, r=25):

In NetLogo however, I don't know how to set r = 25, without having an error.

How can I set my WTMC [ n r ] function to WTMC [ n r = 25 ]

So that I can then call my function: show WTMC [ n ], without needing to include the parameter r

Thanks in advance

like image 290
Paolo Bernasconi Avatar asked Oct 21 '22 13:10

Paolo Bernasconi


1 Answers

Unfortunately, this isn't directly possible NetLogo. You can get close however by just making two functions:

to WTMC [ n ]
  full-WTMC n 25
end

to full-WTMC [ n r ]
  ...
end

(In extensions, you can create primitives with optional arguments like this, just not normal netlogo)

like image 50
Bryan Head Avatar answered Oct 27 '22 20:10

Bryan Head