Programming/lisp
lisp 기본함수
구차니
2012. 12. 29. 13:02
xlisp 도움말 발췌
Symbol Functions
Symbol Functions
set the global value of a symbol
(set <sym> <expr>)
You can also use (setf (symbol-value <sym>) <expr>)
<sym> the symbol being set
<expr> the new value
returns the new value
set the value of a symbol
(setq [<sym> <expr>]...)
fsubr. You can also use (setf <sym> <expr>)
<sym> the symbol being set (quoted)
<expr> the new value
returns the last new value or NIL if no arguments
---
define a function
(defun <sym> <fargs> <expr>...)
define a macro
(defmacro <sym> <fargs> <expr>...)
fsubr
<sym> symbol being defined (quoted)
<fargs> formal argument list (lambda list) (quoted)
<expr> expressions constituting the body of the function (quoted)
returns the function symbol
---
> (defun prt () '(be))
prt
> prt
error: unbound variable - prt
if continued: try evaluating symbol again
1> (prt)
(be)
1> (defun add (a b) (+ a b))
add
1> ( add 2 4)
6
1> add
error: unbound variable - add
if continued: try evaluating symbol again
2> (add)
error: too few arguments