[2021 Spring] CS61A 学习笔记 lecture 24 scheme
从这一课开始学习scheme,一种Lisp方言,会讲到与python的比较。
Data Types
We divide Scheme data intoatomsandpairs.
- The classical atoms:
- Numbers: integer, floating-point, complex, rational.
- Symbols.
- Booleans:#t, #f.
- The empty list:().
- Procedures (functions).
- Pairs are like two-element Python tuples, where the elements are (recursively) Scheme values.
Programs
Scheme运算符一般用前缀表达式
Quotation
使用quote 或者 '符号表示引用。
Special Forms
Traditional Conditionals
Symbols
Function Evaluation
Numbers
Lists and Pairs
Equivalence Operations
Binding Constructs: Let
Loops and Tail Recursion
scheme在函数递归时,每次递归调用会替换掉上一次调用,也就是说,不会保存调用过程中的中间数据;python则需要在返回最终结果前保存所有中间值,占用很多内存。