CSCI 431: Functional Programming Languages

LISP

Interacting with LISP

LISP Expressions

Atoms and lists

Evaluation rules for atoms

Evaluation rules for lists

Variables

More on Variables

LISP environment

Let and Local Bindings

Predicates

Defining functions

Examples of user defined predicates

(defun positive (x)
   (>= x 0))
(defun twice (x y)
  (= x (* 2 y)))

When we call twice with these arguments:

(twice 4 2)

The body is

(= x (* 2 y))

Where x is bound to 4 and y is bound to 2. So (* 2 y) returns 4, and x is 4, and = returns t, so twice returns t.

(defun zerop (x) (= x 0))

(defun plusp (x) (> x 0))

(defun minusp (x) (< x 0))

Conditionals

Logical Combinations

A Recursive Function

Cond

Making Lists

Getting Inside Lists

List Related Predicates

Adding Elements to Lists

Boxes and Pointer Notation

Eql

Equal