informaticsEn 2022-02-14 14:26:24
44

Defun and Lambda

DEFUN defines a function with a name.

You can define a named function using the DEFUN macro:

(defun sum (x y)

"Return a number which is the sum of x and y."

  (+ x y))


The defun form has the following:

  • The name of the function: sum
  •  Optional documentation string: "Return a number which is the sum of x and y."
  • A list of argument names: (x y)
  • The body of the function: (+ x y)

DEFUN returns the name of the defined function, so we have the sum as a function.

You can get more information about Functions:

https://gigamonkeys.com/book/functions.html