第 1 章 玩具

这是原子atom吗?
atom
是的,因为atom是一个字母a开头的字符串。

这是原子atom吗?
turkey
是的,因为atom是字母开头的字符串。

这是原子atom吗?
1492
是的,因为1492是数字的字符串。

这是原子atom吗?
u
是的,因为u是字母开头的字符串,仅仅一个字符。

这是原子atom吗?
*abc$
是的,因为atom是字母或者除了括号”(“和“)”外的特殊字符开头的字符串。

这是list表吗?
(atom)2
是的,因为(atom)是一个atom原子外加括号构成。

这是list表吗?
(atom turkey or)
是的,因为它是由一组原子外加括号构成。

这是list表吗?
(atom turkey) or
不是,这是两个没有括起来的两个S-expression表达式,第一个是含有两个atom原子list列,第二个是一个atom原子。

这是list表吗?
((atom turkey) or)
是的,因为这是两个S-expression表达式外加括号构成。

这是S-expression吗?
xyz
是的,因为所有的atom原子都是S-expression表达式。

这是S-expression吗?
(x y z)
是的,因为它是一个list列表。

这是S-expression吗?
((x y) z)
是的,因为所有的list表都是S-expression表达式。

这是list吗?
(how are you doing so far)
是的,因为它是S-expression表达式外加括号组成的。

list表中有多少个 S-expression?
(how are you doing so far)
六个,how, are, you, doing, so, 和far。

这是list吗?
(((how) are) ((you) (doing so)) far)
是的,因为它是S-expression表达式外加括号组成的。

list表中有多少个 S-expression?
(((how) are) ((you) (doing so)) far)
三个,((how) are), ((you) (doing so)), 和 far

这是list吗?
()
是的,因为它是0个S-expression表达式外加括号组成的。这个特殊的S-expression称为null空(或者empty空)

这是atom原子吗?
()
不是,因为()仅仅是一个list表。

这是list吗?
(() () () ())
是的,因为它是S-expression表达式外加括号组成的。

下面的声明中的表l的car是什么
(a b c)

是a,因为a是list表的第一个atom原子

下面的声明中的表l的car是什么
l是((a b c) x y z)

(a b c), 因为(a b c)是这个非空list表的第一个 S-expression表达式。

下面的声明中的表l的car是什么
l是 hotdog

没有答案,atom原子没有car

下面的声明中的表l的car是什么
l是 ()

没有答案,空表没有car。 注脚:L:nil

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Car的规则
基本操作符car仅为非空list表定义。
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

下面的声明中的表l的car是什么
l是(((hotdogs)) (and) (picle) relish)

((hotdogs)),叫做“hotdogs的列表的列表。”((hotdog))是l的第一个 S-expression.

下面的声明中的表l,取(car l)是什么
l是(((hotdogs)) (and) (picle) relish)

((hotdogs)), (car l)是另一种“l的car”的写法。
示意:
   (car ( ((hotdogs)) (and) (picle) relish))
==>       ((hotdogs))

下面的声明中的表l的(car (car l))是什么
l是(((hotdogs)) (and))

(hotdogs)。示意为:
   (car (car (((hotdogs)) (and))))
==>(car       ((hotdogs))        )
==>            (hotdogs)

下面的声明中的表l的cdr是什么
l是(a b c)

(b c), 因为(b c)是l中除了(car l)的部分。
注意:“cdr”发音为“could-er”。

下面的声明中的表l的cdr是什么
l是((a b c) x y z)

(x y z).

下面的声明中的表l的cdr是什么
l是(hamburger)

()。

下面的声明中的表l,取(cdr l)是什么
l是((x) t r)

(t r),因为(cdr l) 仅仅“表l的cdr“的另一种表示方法。

下面的声明中的表l的cdr是什么
l是 hotdogs

没有答案,atom原子没有cdr。

下面的声明中的表l的cdr是什么
l是()

没有答案,空表null没有cdr。
练习:(null? alpha)除了空表外都为假。

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cdr的规则
基本操作符cdr仅为非空list表定义。任何非空list的cdr都是另一个list。
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

下面的声明中的表l,取(car (cdr l))是什么
l是((b) (x y) ((x)))

(x y), 因为((x y) ((c)))是(cdr l), (x y) 是(cdr l)的car。示意:
   (car (cdr     ((b)     (x y) ((x)))))
==>(car          (        (x y) ((x)))))
==>                       (x y)

下面的声明中的表l,取(cdr (cdr l)) 是什么
l是((b) (x y) ((x)))

(((x))), 因为((x y) ((c)))是(cdr l),而(x y)是(cdr l)的car。
示意:
   (cdr (cdr ((b)     (x y)     ((x)))))
==>(cdr      (        (x y)     ((x)))))
==>          (                  ((x)) )

下面的声明中的表l,取(cdr (car l))
l是(a (b (c)) d)

没有答案,因为(cdr l)是一个atom原子,它不能取cdr了。

car 的参数可以是什么

任何非空list表。

cdr 的参数可以是什么
任何非空list表。

假设a是 peanut,l是(butter and jelly),那么a和l的cons(这通常写作"(cons a l)",读作把atom原子a cons到list表l上)是什么

(peanut butter and jelly),因为cons把一个atom原子追加到list表最前头。
示意:
   (cons a (butter and jelly)
==>(peanut (butter and jelly)

假设s是(banana and),l是(peanut butter and jelly),那么把scons到l上是什么

((banana and) peanut butter and jelly),因为cons任意 S-expression追加到list表最前头。
示意:
   (cons (banana and)    (peanut butter and jelly) )
==>     ((banana and)     peanut butter and jelly)

假设s是((help) this),l是(is very ((hard) to learn)),那么(cons s l) 是什么

(((help) this) is very ((hard) to learn))。
示意:
   (cons ((help) this)    (is very ((hard) to learn)) )
==>     (((help) this)     is very ((hard) to learn))

cons 的参数可以是什么

cons带两个参数,第一个可以是任何 S-expression,第二个是任意list表。

假设s是 (a b (c), l是(),那么 (cons s l) 是什么

((aa b (c)))

假设s是 a, l是(),那么 (cons s l) 是什么

(a)

假设s是 ((a b c)), l是b,那么 (cons s l) 是什么

没有答案,因为l不是list不能cons。

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cons的规则

基本操作符cons有两个参数。cons的第二个参数必须是list表,结果返回一个list表。
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

假设s是a,l是((b) c d),那么(cons s (car l))是什么

(a b)
示意:
   (cons a (car ((b) c d) ))
==>(cons a       (b)       )
==>     (a        b)

假设s是a,l是((b) c d),那么(cons s (cdr l))是什么

(a c d)。
示意:
   (cons a (cdr ((b) c d) ))
==>(cons a      (    c d)  )
==>     (a           c d)

假设l是(),那么l是null list表,对么

是的,因为它是一个含有0个 S-expression表达式的list列表。

(null? (quote ()) 是什么

true真。因为(quote())是空表null的写法。
注:L:空表可以是()或者'(),S:可以是'()。是否是空表,L:null。

假设l是(a b c),那么(null? l)是真还是假

假。L是非空集。

假设A是SPAGHETI,那么(NULL? A)是真还是假

没有答案,ATOM原子没有真假。

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Null的规则

基本操作符null?仅仅为list表定义
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

假如s是harry,那么s是否是atom原子

真。因为harry是字母开始的字符串。

如果 s 是 harrry 那么(atom? s)是什么

真。因为 (atom? s) 是另外一种表达”s是否是一个atom原子“的方式。
注:
L:(defunation? (x)
    (not (listp x)))
S:(define atom?
    (lambda (x)
        (and (not (pair? x)) (not (null? x))))

假如s是 (Harry had a heap of apples),那么 (atom? s) 是真是假

假。因为s是一个list表。

atom?有几个参数

一个。这个参数可以是任意 S-expression。

假如s是 (Harry had a heap of apples),那么 (atom? (car l)) 是真是假

真。
示意:
   (atom? (car (Harry had a heap of apples))
==>(atom?       Harry                      )
==>true

假如s是 (Harry had a heap of apples),那么 (atom? (cdr l)) 是真是假

假。
示意:
   (atom? (cdr (Harry had a heap of apples) ) )
==>(atom?            (had a heap of apples)   )
==>false

假如s是 (swing low sweet cherry oat) ,那么 (atom? (car (cdr l))) 是真是假
真。
示意:
   (atom? (car (cdr (swing low sweet cherry oat))))
==>(atom? (car            (low sweet cherry oat)) )
==>(atom?                  low                 )  )
==>true

假如s是 (swing (low sweet) cherry oat) ,那么 (atom? (car (cdr l))) 是真是假

假。
示意:
   (atom? (car (cdr (swing (low sweet) cherry oat))))
==>(atom? (car            ((low sweet) cherry oat)) )
==>(atom?                  (low sweet)              )
==>false

假如 a1是 Harry,a2是 Harry,那么 a1和a2 是否相等

真。因为a1和a2完全相同。

假如 a1是 Harry,a2是 Harry,那么 (eq? a1 a2) 是真还是假

真。因为 (eq? a1 a2) 是另外一种表达”a1和a2是否是同一个非数值atom原子“的方式。
注:Lisp:eq

假如 a1是 margarine,a2是 butter,那么 (eq? a1 a2) 是真还是假

假。a1和a2不同。

eq?需要多少参数?各是什么?

两个参数,都是非数值atom原子。

假设l1是(),l2是 (strawberry),那么 (eq? l1 l2)是真还是假

没有答案,()和(strawberry)是list表。
注:实际当中是可以作为eq?的参数的。

假设n1是6,n2是7,那么 (eq? n1 n2)是真还是假

没有答案,因为两个参数是数字。
注:实际当中是可以作为eq?的参数的。

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
eq?的规则
基本操作符eq?带有两个参数,两个都是非空数值的atom原子
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

假设l是 (Mary had a little lamb chop),a是 Mary,那么(eq? (car l) a) 是真还是假

真。

假设l是 (soured milk),a是 Mary,那么(eq? (cdr l) a) 是真还是假

没有答案。

假设l是 (beans beans we need jelly beans),(eq?(car l) (car (cdr l))) 是真还是假

真。因为这是在比较list表中的第一个和第二个atom原子。

==>现在去,做出自己的花生酱果冻三明治<==


This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 China Mainland License.

the little schemer 笔记(1)的更多相关文章

  1. the little schemer 笔记(0)

    the little schemer 笔记 Z.X.L 2012年08月13日 五项规则 car的规则car只对非空列表有定义. cdr的规则cdr只对非空列表有定义.任何非空列表的cdr是另外一个列 ...

  2. the little schemer 笔记(10)

    第十章 What Is  the Value of All of This? entry条目 是由list表组成的 pair 对,pair 对的第一个list表是集合 set.另外,两个list表的长 ...

  3. the little schemer 笔记(3)

    第三章 cons the magnificent (rember a lat)是什么,其中a是mint,lat是(lamb chops and mint jelly) (lamb chops and ...

  4. the little schemer 笔记(10.1)

    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 China Mainla ...

  5. the little schemer 笔记(9)

    第九章 ...and Again, and Again, and, Again, ... 你想来点鱼子酱吗? 那就去找它吧. (looking a lat)是什么,其中a是 caviar, lat是( ...

  6. the little schemer 笔记(8)

    第八章 lambda the ultimate 还记得我们第五章末的rember和insertL吗 我们用equal?替换了eq? 你能用你eq?或者equal?写一个函数rember-f吗 还不能, ...

  7. the little schemer 笔记(5)

    第五章 “Oh My Gawd”:It's Full of Stars (rember* a l)是什么,其中a是cup,l是((coffee) cup ((tea) cup) rember*发音为r ...

  8. the little schemer 笔记(7)

    第七章 Friends and Relations 这是一个set集合吗 (apple peaches apple plum) 不是,apple出现了不止一次 (set? lat) 是真还是假,其中l ...

  9. the little schemer 笔记(6)

    第六章 Shadows 1 是算术表达式吗 是 3 是算术表达式吗 是的 1+3 是算术表达式吗 是的 1+3×4 是算术表达式吗 当然是 cookie 是算术表达式吗 是啊,你需要来一块吗 e那么 ...

  10. the little schemer 笔记(4)

    第四章 numbers games 14 是原子吗 是的,数都是原子 (atom? n) 是真还是假,其中n是14 真,14 是原子 -3是数吗 是的,不过我们暂不考虑负数 3.14159是数吗 是的 ...

随机推荐

  1. 利用ms17_010漏洞实验

    1.理论 在MSF里面msfconsole可以说是最流行的一个接口程序.但是msfconsole真的是一个强大的接口程序.Msfconsole提供了一个一体化的集中控制台.通过msfconsole,你 ...

  2. ViewPagerTransforms

    https://github.com/eltld/ViewPagerTransforms

  3. Preference+PreferenceArray+DataModel

    在Mahout中,用户的喜好被抽象为一个Preference,包含了userId,itemId和偏好值(user对item的偏好).Preference是一个接口,它有一个通用的实现是GenericP ...

  4. JavaScript 实现块级作用域

    (function(){ 块级作用域: })();

  5. HDFS运维和优化

    常见问题 下面列举HDFS运行过程中可能出现的常见问题及解决方法,这些问题一般都会在日志中出现的相应的记录.Incompatible clusterIDs in … :namenode cluster ...

  6. codeforces B. Shower Line 解题报告

    题目链接:http://codeforces.com/contest/431/problem/B 题目意思:给出5 * 5 的矩阵.从这个矩阵中选出合理的安排次序,使得happiness之和最大.当第 ...

  7. html5--6-28 css盒模型4

    html5--6-28 css盒模型4 实例 学习要点 了解盒模型 元素内容.内边距.边框 和 外边距 了解盒模型的概念: CSS 盒模型规定了处理元素内容.内边距.边框 和 外边距 的方式. 最内部 ...

  8. [Selenium] WebDriver 操作 HTML5 中的 drag/drop

    以 jQuery UI 官方网站元素测试,地址:http://jqueryui.com/draggable/ 示例: package com.learningselenium.html5; impor ...

  9. RadioGroup和RadioButton

    Activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&qu ...

  10. 斯坦福CS231n—深度学习与计算机视觉----学习笔记 课时8&&9

    课时8 反向传播与神经网络初步(上) 反向传播在运算连路中,这是一种通过链式法则来进行递推的计算过程,这个链路中的每一个中间变量都会对最终的损失函数产生影响. 链式法则通常包含两部分,局部梯度和后一层 ...