Defines a function
(lambda arguments expression ... )
(defun name arguments expression ... )
Examples
(defun square (x) (* x x)) |
|
(square 4) |
|
(setq square2 (lambda (x) (* x x)) ) |
|
(square2 4) |
|
(mapcar '(lambda (x) (* 2 x)) '(1 2 3 4) ) |
|
(defun average (alist) (/ (apply '+ alist) (length alist)) ) |
|
(average '(2 4 6 8)) |
|
(defun dotproduct (v1 v2) (apply '+ (mapcar '* v1 v2)) ) |
|
(dotproduct '(1 2 3) '(2 3 4)) |
This website has been archived and is no longer maintained.