4 ways to do functions in lisp

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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: