Setting default argument value in Racket

Vladimir Keleshev picture Vladimir Keleshev · Aug 20, 2011 · Viewed 7.2k times · Source

Is it possible to set a default value to some of arguments in Racket?

Like so in Python:

def f(arg=0)
    ...

Answer

dyoo picture dyoo · Aug 20, 2011

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!