跳到主要内容

学习 The Little Schemer

· 阅读需 2 分钟

环境配置使用 VS Code 编写 scheme ,参考: Windows + VS Code 搭建 Scheme 开发环境 - 知乎

基本语法

atom: 元子 atom

list: 列表 (atom ss) ()

car: list 里的第一个 元素 (car l)

The primitive car is definedonly for non-empty lists.

( car l) is another way to ask for "the car of the list l."

cdr: list 去掉 car 后的 新 list cdr l

( cdr l) is just another way to ask for "the cdr of the list l."

car: cdr都是针对非空 list,不能用于atom,空list

cons: 把 一个 Scheme expression 添加为list的第一个元素. (cons a l) 第二个参数一定是list.

(null? l): 是空list吗? (quote ())表示一个空 list,null list. ( null? (quote ())) => true

( atom? s )atom吗?

( eq? a1 a2) 这两个atom相等吗? Eq takes two arguments. Both of them must be non-numeric atoms.

----------------第一章 end (lat? l) 是全为atomlist吗? Every lat is a list of atoms.