Is it possible to set a default value to some of arguments in Racket?
Like so in Python:
def f(arg=0)
...
Python allows function arguments to have default values. If the function is called without the argument, the argument gets its default value.
A default argument is a value provided in a function declaration that is automatically assigned by the compiler if the calling function doesn't provide a value for the argument. In case any value is passed, the default value is overridden.
Any number of arguments in a function can have a default value.
Yes; take a look at: declaring optional arguments.
For example:
(define (f [arg 0])
(* arg 2))
Racket also supports functions with keyword arguments. The link should lead to documentation that talks about them too. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With