⇦ Back to Janet API Survey

% (function)

% is the remainder operator/function—not to be confused with mod (i.e., modulo).

repl> (root-env '%)
@{:doc "(% & xs)\n\nReturns the remainder of dividing the first value of xs by each remaining value."
  :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" 145 1)
  :value <function %=>}

Things I Learned

Created:

Updated: