摘要: (defun single? (lst) (and (consp lst) (null (cdr lst)))) CL-USER> (single? nil)NILCL-USER> (single? '(a))T (defun append1 (lst obj) (append lst (list obj))) CL-USER> (append1 '(a b c d) 'e)(A B C D ... 阅读全文
posted @ 2012-12-20 22:10 flowjacky 阅读(237) 评论(0) 推荐(0)
摘要: a.如果在一般形参前CL-USER> (defun hey (x &rest args) (member x args))HEYCL-USER> (hey '1 '(2 1 3))NILCL-USER> (hey '1 '2 '1 '3)(1 3)CL-USER> (member '1 '(2 1 3))(1 3)CL-USER> (defun world (&rest fn) fn)WORLDCL-USER> (world 'a 'b)(A B)CL-USER& 阅读全文
posted @ 2012-12-20 14:37 flowjacky 阅读(203) 评论(0) 推荐(0)
摘要: do: (do ((x a (b x)) (y c (d y))) ((test x y) (z x y)) (f x y)) 局部函数: (labels ((rec (x y) (cond ((test x y) (z x y)) (t (f x y) (rec (b x) (d y)))))) (rec a c)) 说明:上面代码中的b,d,test,z,f均为函数。 阅读全文
posted @ 2012-12-20 11:35 flowjacky 阅读(148) 评论(0) 推荐(0)
摘要: 将下列表达式翻译成没有使用let与let*,并使用同样的表达式不被求值2次。 (a). (let ((x (car y))) (cons x x)) (b). (let* ((w (car x)) (y (+ w z))) (cons w y)) 答案: (a). ((lambda (x) (cons x x)) (car y)) (b). ((lambda (w) ((lambda (y) ... 阅读全文
posted @ 2012-12-19 14:31 flowjacky 阅读(111) 评论(0) 推荐(0)
摘要: (defconstant month #(0 31 59 90 120 151 181 212 243 273 304 334 365)) (defconstant yzero 2000) (defun leap? (y) (and (zerop (mod y 4)) (or (zerop (mod y 400)) (not (zerop (mod y 100)))))) (defun date-... 阅读全文
posted @ 2012-12-19 13:59 flowjacky 阅读(193) 评论(0) 推荐(0)
摘要: (defun leap? (y) (and (zerop (mod y 4)) (or (zerop (mod y 400)) (not (zerop (mod y 100)))))) 说明 闰年: 普通年:能被4整除 世纪年:能被400整除 阅读全文
posted @ 2012-12-19 08:59 flowjacky 阅读(365) 评论(0) 推荐(0)
摘要: 4.7节的图4.4是这个样子,我认为改成这样才是对的,2和3应该换个位置。 阅读全文
posted @ 2012-12-18 08:20 flowjacky 阅读(107) 评论(0) 推荐(0)
摘要: (defun second-word (str) (let ((pl (+ (position #\ str) 1))) (subseq str pl (position #\ str :start pl)))) 阅读全文
posted @ 2012-12-15 13:41 flowjacky 阅读(202) 评论(0) 推荐(0)
摘要: 1 (defun mirror? (s)2 (let ((len (length s)))3 (if (evenp len)4 (do ((start 0 (+ start 1))5 (end (- len 1) (- end 1)))6 ((or (> start end)7 (not (equal (elt s start)8 (elt s end))))9 (> start end))))))相... 阅读全文
posted @ 2012-12-15 10:37 flowjacky 阅读(236) 评论(0) 推荐(0)
摘要: P23:大公司为了避免设计上的灾难,选择了减少设计结果的标准差。但是当你排斥差异的时候,你不仅将失败的可能性排除在外,也将获得高利润的可能性排除在外。《黑客与画家》P25:黑客如何才能做自己喜欢的事情?我认为这个问题的解决方法是一个几乎所有创作者都知道的方法:找一份养家糊口的“白天工作”(day job)。这个词是从音乐家身上来的,他们晚上表演音乐,所以白天可以找一份其他工作。更一般地说,“白天工... 阅读全文
posted @ 2012-12-11 16:38 flowjacky 阅读(259) 评论(0) 推荐(0)