*
(function)
*
is the multiply operator/function.
repl> (root-env '*)
@{:doc "(* & xs)\n\nReturns the product of all elements in xs. If xs is empty, returns 1."
:value <function *>}
*=
(macro)
There is also a macro variant that mutates its first argument.
repl> (macex '(*= x 2))
(set x (<function *> x 2))
repl> (root-env '*=)
@{:doc "(*= x & ns)\n\nShorthand for (set x (\\* x n))."
:macro true
:source-map ("boot.janet" 143 1)
:value <function *=>}
Things I Learned
- Without arguments,
*
returns 1. *
is variadic.*
corresponds to themul
instruction in the abstract machine.*
is implemented via C’s*
operator.- Arbitrary objects can be used with the
*
function if the object in question implements the:*
or:r*
methods.