📄 http:^^www.cs.washington.edu^education^courses^415^prog2.solution.html
字号:
Date: Mon, 02 Dec 1996 14:42:34 GMTServer: NCSA/1.4.2Content-type: text/html<HEADER><TITLE>CSE 415 Prog. Assignment 2 Solution</TITLE></HEADER><BODY><pre>Note that by simplifying the sub expressions into a1 and a2, we avoid theproblem of having to run the simplify algorithm multiple times.(defun simplify (e) (cond ((atom e) e) (t (let ((a1 (simplify (arg1 e))) (a2 (simplify (arg2 e)))) (cond ((equal (op e) '*) (cond ((equal a1 0) 0) ((equal a2 0) 0) ((equal a1 1) a2) ((equal a2 1) a1) (t `(* ,a1 ,a2)))) ((equal (op e) '+) (cond ((equal a1 0) a2) ((equal a2 0) a1) (t `(+ ,a1 ,a2)))) ((equal (op e) '-) (cond ((equal a2 0) a1) (t `(- ,a1 ,a2)))) ((equal (op e) 'expt) (cond ((equal a2 1) a1) (t `(expt ,a1 ,a2)))))))))where op arg1 and arg2 extract the first, second, and third elementsof a list.</body>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -