simply scheme 第六章 练习
来源:互联网 发布:美迪惠尔 丽得姿 知乎 编辑:程序博客网 时间:2024/06/03 12:45
6.1 nowhere man,3,goes
6.2 #t #f #f #t #t #t
6.3 (define (sign number)
(cond ((< number 0) 'negative)
((= number 0) 'zero)
(else 'positive)))
6.4 (define (utensil meal)
(if (equal? meal 'chinese) 'chopsticks 'forks))
6.5 (define (european-time st)
(cond ((equal? st '(12 pm)) 12)
((equal? st '(12 am)) 24)
((equal? (last st) 'am) (first st))
((equal? (last st) 'pm) (+(first st) 12))))
(define (american-time wd)
(cond ((equal? wd '12) '(12 PM))
((equal? wd '24) '(12 AM))
((< wd 12) (se wd 'AM))
((> wd 13) (se (- wd 12) 'PM))))
6.6 (define (teen arg)
(if (and (>= arg 13)(<= arg 19)) #t #f))
6.7 (define (type-of st)
(cond ((number? st) 'number)
((boolean? st) 'boolean)
((word? st) 'word)
(else 'sentence)))
6.8 (define (indef-article wd)
(if (vowel? (first wd)) (se 'an wd) (se 'a wd)))
(define (vowel? letter)
(member? letter 'aeiou))
6.9 (define (thismany arg1 arg2)
(if(< arg1 2) (se arg1 arg2) (se arg1 (word arg2 's))))
6.10 (define (sort2 st)
(if(< (last st) (first st)) (se (last st)(first st)) st))
6.11
(define (valid-date? a1 a2 a3)
(if (and (< a1 13)(> a1 0)(> a3 0)) (check a1 a2 a3) #f))
(define (check a1 a2 a3)
(cond((member? a1 '(1 3 5 7 8 10 12)) (if (and(> a2 0) (< a2 32)) #t #f))
((= a1 2) (if (leapyear? a3)
(if(and(> a2 0)(< a2 30)) #t #f)
(if(and(> a2 0)(< a2 29)) #t #f)))
((member? a1 '(4 6 9 11)) (if(and(> a2 0)(< a2 31)) #t #f))))
(define (leapyear? a)
(if(div a 100)
(if(div a 400) #t #f)
(if(div a 4) #t #f)))
(define (div x y)
(if(=(remainder x y) 0) #t #f))
6.14
(define (describe-time wd)
(cond ((< wd 60)
(convert wd 'second))
((< wd (* 60 60))
(convert (/ wd 60) 'minute))
((< wd (* 60 60 24))
(convert(/ wd (* 60 60))'hour))
((< wd (* 60 60 24 30))
(convert(/ wd(* 60 60 24))'day))
((< wd (* 60 60 24 30 12))
(convert(/ wd(* 60 60 24 30))'month))
((< wd (* 60 60 24 30 12 100))
(convert(/ wd(* 60 60 24 30 12))'year))
(else (convert (/ wd(* 60 60 24 30 12 100))'century))))
(define (convert a b)
(se a (if(= a 1) b (word b 's))))
- simply scheme 第六章 练习
- simply scheme 第二章 练习
- simply scheme 第三章 练习
- simply scheme 第四章 练习
- simply scheme 第五章 练习
- simply scheme 第七章 练习
- simply scheme 第八章 练习
- simply scheme 第九章 练习
- simply scheme 第十一章 练习
- simply scheme 第十二章 练习
- simply scheme 第十三章 练习
- simply scheme 第十四章 练习
- simply scheme 第十五章 练习
- simply scheme 第一章 练习+ 看书计划
- 第六章练习答案
- 第六章上机练习
- 第六章上机练习
- 第六章练习
- 关于CFile读取文件的问题GetLength(),,,万恶的CFile不如|CStdioFile
- 招聘c++项目经理
- 听歌所想-----王菲“传奇”
- 短信端到端业务知识
- “图标无法拖至拽快速启动栏”的解决方法
- simply scheme 第六章 练习
- 支持动态属性的标签库
- RAID服务器重组入门分析
- RAID5同时坏两块硬盘的处理办法
- SOA项目实施的难题
- linux-2.6.32内核 linux-fusion-8.1.1编译错误解决方法
- 国内5大免费智能DNS解析
- 讨厌这个离别的季节!可爱的舍友,祝福你们!
- 关于可重入函数和不可重入函数