4 ways to do functions in lisp

June 16, 2008

With lisp you can not only pass variables into functions but also pass functions into other functions.

1. This function has no abstraction whatsoever.

(defun does-everything ()
(
< 1 2))

2. The predicate function is passed into the function. The number values are constants.

(defun does-constants (fn)

(funcall fn 1 2))

3. The number values are passed into the function.

(defun does-function (x y)

(< x y))

4.Everything is abstracted out, the predicate function and number values are abstracted out.

(defun does-nothing (fn x y)

(funcall fn x y))

The functions could be further refined to take advantage of the abstractions, but for a basic knowledge these are the basic functions.