function
(apply f & args )
Applies a function f 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 or a tuple. Each
element in this last argument is then also pushed as an argument to
f.
# 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