#Code
lisp-let变量声明
lisp声明、使用变量的一种方法,是使用let语句。
形如:
;(let ((variable declare1) (variable declare2) (...))
; (varaible used here));
(defun foo(x)
(format t "Parameter: ~a~%" x)
(let ((x 2))
(format t "Outer LET: ~a~%" x)
(let ((x 3))
(format t "Inner LET: ~a~%" x))
(format t "Outer LET: ~a~%" x))
(format t "Parameter: ~a~%" x));
(foo 10);
·1min·李岩
lisp-let变量声明lisp-lambda函数
lisp中的lambda表达式,显然和python中的很相似。
参照《实用common lisp编程》:
;按照 min max, 步长step为参数的fn计算的长度输出 *
(defun plot (fn min max step)
(loop for i from min to max by step do
(loop repeat (funcall fn i) do (format t "*"))
(format t "~%")))
(plot #'exp 0 4 1/2);
(plot #'(lambda (x) (* 2 x)) 0 10 1);
·1min·李岩
lisp-lambda函数clisp编译
·1min·李岩
clisp编译lisp-hello world
·1min·李岩
lisp-hello world