Name

defun

Usage

special-form

Syntax

(defun name (arg*) [doc-string] form*)

Description

Defines a global function.

user > (defun f (x y) (+ x y))
it: f
user > (f 21 34)
it: 55

With optional parameters:

user > (defun f (x &optional (y 2)) (+ x y))
it: f
user > (f 3 4)
it: 7
user > (f 3)
it: 5

With named parameters:

user > (defun f (x &key (y 2) (z 3)) (+ x y z))
it: f
user > (f 3 :y 4)
it: 10
user > (f 3 :z 9 :y 77)
it: 89

See also

about:parameters defun* lambda lambda*