首页 > 代码库 > SICP_2.53-2.55
SICP_2.53-2.55
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。