Lisp 是一种动态类型的函数式编程语言,它非常适合用来写计算器。以下是一个简单的 Lisp 计算器代码:
(defun calculate (expr)
(cond ((eq (first expr) '+)
(+ (second expr) (third expr)))
((eq (first expr) '-)
(- (second expr) (third expr)))
((eq (first expr) '*)
(* (second expr) (third expr)))