加载中
递归

scheme代码: ;;; Method1 -- count the sum of digit before x (define (sum1 x)   (do ((n 0 (+ 1 n))        (sum 0 (+ sum n)))     ((> n x) sum...

2016/02/19 01:48
93
Common Lisp牛顿法求平方根

1)牛顿法求平方根: 公式:(y + x/y) / 2,首先猜测为1,然后逐渐逼近。 (defun sqrt-iter (guess x)   (if (good-enough? guess x)       guess       (sqrt-iter (...

2016/02/03 03:34
517
Common Lisp 宏

1)简单的宏 CL-USER> (defmacro print-test (x y)        `(format t "~A ~A~%" ,x ,y)) PRINT-TEST CL-USER> (print-test 'hello 'world) HELLO WORLD NIL 2) 3)...

2016/01/14 00:10
199
Common Lisp简单排序

1)用sort函数进行排序 CL-USER> (sort "elbow" #'char<) "below" CL-USER> (sort '(a c b s) #'string<) (A B C S) CL-USER> (sort '(39 48 28 4 32) #'<) (4 28 32 ...

2016/01/07 00:42
631
Common Lisp集合运算

集合论中的并集 (union)、交集 (intersection)以及补集 (complement)的实现,是由函数 union 、 intersection 以及 set-difference 。还有判断数组蕴涵subsetp CL-USER> (setf list1 '(a...

2016/01/05 00:14
191
Common Lisp专题4:数组

1)用make-array创建数组: CL-USER> (make-array 5 :initial-element nil) #(NIL NIL NIL NIL NIL) CL-USER> (make-array 5 :initial-contents '(a e i o u)) #(A E I O...

2016/01/03 22:02
401
Common Lisp专题3:文件操作

1)读取文件 用with-open-file函数打开文件 CL-USER> (defun my-read-file ()        (with-open-file (stream "d:/test.lisp")          (do ((my-file (read-line ...

2015/12/28 00:06
995
Common Lisp循环和递归

循环: 1)do循环 语法:(do ((变量名 变量初值 (变量变化语句))) (结束条件 返回值) 循环主体) CL-USER> (defun draw-line (x)        (do ((i 0 (1+ i)))          ...

2015/12/27 02:08
531
Common Lisp专题1:Function and Data

1)基本的数学函数: + Adds two numbers - Subtracts the second number from the first * Multiplies two numbers / Divides the first number by the second ABS Absolute value of a numb...

2015/12/27 01:48
86

没有更多内容

加载失败,请刷新页面

没有更多内容

返回顶部
顶部