断断续续看完第一章的三节公开课,做完第一章的课后习题,回顾一下。
Lisp的基本语法
组合式的概念
例如: (+ 3 (* 5 6))
表达式类型
numbers
symbol
lambda-expressions
definitions
conditionals(条件表达式)
combinations(组合式)
例如:
1
2(define a (* 5 5)) ;a是符号
(define (a) (* 5 5)) ;a是过程
应用序和正则序
应用序:先求参后应用
正则序:先展开后规约线性递归(Linear-Recurison)与迭代(Iteration),时间复杂度、空间复杂度简单分析
函数式编程(functional programming)将过程(函数)作为参数,返回值等等
例如:
1 | (define (compose f g) |
复杂问题的分析与分解,划分成一个个自问题来解决
语法糖衣(syntactic sugar)
lambda
以下两种定义等价,都是f(x) = x + 1
1 | (define (f x) (+ x 1)) |
1 | (define f |
let
以下两种定义等价,都是f(x) = 2x + 1
1 | (define (f x) |
1 | (define (f x) |