SICP Exercise 1.22
(define (timed-prime-test n)
(newline)
(display n)
(start-prime-test n (runtime)))
(define (start-prime-test n start-time)
(if (prime? n)
(report-prime (- (runtime) start-time))))
(define (report-prime elapsed-time)
(display " *** ")
(display elapsed-time))
这边使用 Drscheme时,会出错,显示没有runtime过程。
解决方法是 选择语言 PLT-MZscheme 然后将程序改为下面的:
(define (timed-prime-test n)
(newline)
(display n)
(start-prime-test n (current-milliseconds)))
(define (start-prime-test n start-time)
(if (prime? n)
(report-prime (- (current-milliseconds) start-time))))
(define (report-prime elapsed-time)
(display " *** ")
(display elapsed-time)
(display " ms "))
(timed-prime-test 100000000057)
那么这道题就是这么写了:
(define (f start count)
(cond ((= 0 count)
(newline)
(display "***** FINISHED *****")
(newline))
((timed-prime-test start) (f (+ 2 start) (- count 1)))
(else (f (+ 2 start) count))))
(define (search-for-primes a)
(f (+ a 1) 3))
(search-for-primes 1000)
分享到:
相关推荐
SICP 使用的scheme解释器 以前叫DrScheme
sicp in python 中文版 sicp in python 中文版 sicp in python 中文版 !!!download>>>https://github.com/wizardforcel/sicp-py-zh
SICP中文第二版SICP中文第二版SICP中文第二版SICP中文第二版SICP中文第二版
SICP-Python版本
sicp 2.2.4节图形语言的racket程序包,配置路径,C:\Users\Administrator\AppData\Roaming\Racket
Python SICP epub版本,很适合学习抽象的思想,用Python版本比lisp更实用
SICP 解题集
SICP CHINESE ENGLISH THE SECOND EDITION SICP CHINESE ENGLISH THE SECOND EDITION
SICP 习题答案 计算机程序的构造和解释 1-3章 习题答案
sicp in python 中文版 sicp in python 中文版 sicp in python 中文版 download : https://github.com/wizardforcel/sicp-py-zh
SICP习题解答,主要第一章的内容习题答案
sicp-in-python(中文版+英文版)PDF 背景. SICP 全称Structure and Interpretation of Computer Programs,翻译过来叫《计算机程序的构造和解释》使用python
资源来自pypi官网。 资源全名:sicp-0.0.1b102.dev4.tar.gz
资源名称:sicp 和 操作系统:精髓与设计原理第七版资源截图: 资源太大,传百度网盘了,链接在附件中,有需要的同学自取。
经典书籍《计算机程序的构造与解释》,UCB热门课程CS61a的官方教材
#SICP SICP解决方案
sicp
Structure and Interpretation of Computer Programs
sicp 2ed高清pdf,以及相对应的mit课程资料及习题答案打包,中文版的视频在这里http://i.youku.com/i/UNTcxODk3ODQw/videos?spm=a2hzp.8244740.0.0