function
(apply f & args)
Applies a function to a variable number of arguments. Each element
in args is used as an argument to f, except the last element in
args, which is expected to be an array-like. Each element in this
last argument is then also pushed as an argument to f. For example:
(apply + 1000 (range 10))
sums the first 10 integers and 1000.
# Contrived examples returning the variadic arguments passed in.
(defn example-function [& args] args)
(defmacro example-macro [& args] ~(tuple ,;args))
(macex '(example-macro 1 2 3))
(assert (= (example-function 1 2 3)
(example-macro 1 2 3)))
(def args [1 2 3])
# `apply` is for functions, but there's always `eval`.
(assert (= (apply example-function args)
(eval ~(example-macro ,;args))))
# Same return for both.
# => (1 2 3)
(apply * [1 2 3]) # -> 6
(* (splice [1 2 3])) # -> 6
(* ;[1 2 3]) # -> 6
(* 1 2 3) # -> 6