5

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

Paolo Bernasconi
  • 2,010
  • 11
  • 35
  • 54

1 Answers1

3

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)

Bryan Head
  • 12,360
  • 5
  • 32
  • 50