码迷,mamicode.com
首页 > 其他好文 > 详细

SICP_2.53-2.55

时间:2017-02-24 21:00:50      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:sock   log   单引号   pair   lan   sicp   rac   als   引号   

 1 #lang racket
 2 
 3 ;;;;;;;;;;;;;;;;;;2.53
 4 (define (memq item x)
 5   (cond ((null? x) false)
 6         ((eq? item (car x)) x)
 7         (else (memq item (cdr x)))))
 8 
 9 (list a b c)
10 
11 (list (list george))
12 
13 (cdr ((x1 x2) (y1 y2)))
14 
15 (cadr ((x1 x2) (y1 y2)))
16 
17 (pair? (car (a short list)))
18 
19 (memq red ((red shoes) (blue socks)))
20 
21 (memq red (red shoes blue socks))
22 
23 ;;;;;;;;;;;;;;;2.54
24 (define (equal? a b)
25   (cond ((and (pair? a) (pair? b)
26               (equal? (car a) (car b))
27               (equal? (cdr a) (cdr b)))
28          true)
29         ((eq? a b) true)
30         (else false)))
31 
32 ;;;;;;;;;;;;;test
33 (equal? (this is a list) (this is a list))
34 
35 (equal? (this is a list) (this (is a) list))
36 
37 ;;;;;;;;;;;;;;2.55
38 (car ‘‘abracadara)
39 
40 (car (quoto abracadara))

"  ‘ " 相当于是单引号,只不过省略了后半引号

SICP_2.53-2.55

标签:sock   log   单引号   pair   lan   sicp   rac   als   引号   

原文地址:http://www.cnblogs.com/tclan126/p/6440198.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!