CHP2
(cond ...) 功能為判斷;
(lambda (var...) exp) 創(chuàng)建一個含參數(shù)var...的過程植旧,具體內(nèi)容由exp決定辱揭;
(define var exp) 定義一個新變量离唐,并把exp的求值結(jié)果賦給它;
規(guī)則一
在任何過程中问窃,總是先判斷是否為空表(null?)亥鬓。
CHP3
規(guī)則二
使用cons構(gòu)建列表(list)。
規(guī)則三
當(dāng)構(gòu)建列表(list)時域庇,先拿到特有元素(typical element)嵌戈,然后cons它到傳統(tǒng)遞歸(natural recursion)上。
(cons (car lat) (insertL new old (cdr lat)))
規(guī)則四
當(dāng)遞歸時听皿,至少要改變一個參數(shù)咕别,并該參數(shù)要不斷地向終止條件靠近,同時該參數(shù)要用于終止條件的判斷中写穴。
- 當(dāng)使用cdr時,終止條件用null?雌贱;
- 當(dāng)使用sub1時啊送,終止條件用zero?;
The First Commandment: Always ask null? as the first question in expressing any function.
The Second Commandment: Use cons to build lists.
The Third Commandment: When building a list, describe the first typical element,and then cons is onto the natural recursion.
The Fourth Commandment: Always change at least one argument while recurring. It must be changed to be closer to termination. The changing argument must be tested int the termination condition; when using cdr, test termination with null?
CHP4
元組(tuple)
它是一個由數(shù)字組成的元素集合欣孤。