-
Notifications
You must be signed in to change notification settings - Fork 153
Argumentless Functions
Dave DeLong edited this page Sep 18, 2015
·
1 revision
Normally, a function is entered in the form function(parameter, parameter)
. However, the tokenizer can also recognize functions as simply function
. In this case, the opening and closing parentheses are injected into the token stream. This is only useful when entering constants, since these are the only functions which do not accept parameters. The upshot of this is that you can pass the string "π + e"
and it will be correctly parsed as if you had passed "π() + e()"
.
If you attempt to use this with other functions, an error will be generated and evaluation will fail. This makes sense since (for example) sin()
cannot be evaluated; the sin
function requires a parameter.