内容 3.5 Streams · 270
练习 自检推理
Exercise 3.58: Give an interpretation of the
stream computed by the following procedure:
(define (expand num den radix)
(cons-stream
(quotient (* num radix) den)
(expand (remainder (* num radix) den)
den
radix)))
(Quotient is a primitive that returns the integer quotient of two
integers.) What are the successive elements produced by (expand 1 7
10)? What is produced by (expand 3 8 10)?
练习 3.58:解释以下过程所计算的流的含义:
(define (expand num den radix)
(cons-stream
(quotient (* num radix) den)
(expand (remainder (* num radix) den)
den
radix)))
(Quotient 是一个基本过程,返回两个整数相除的整数商。)(expand 1 7 10) 依次产生哪些元素?(expand 3 8 10) 产生什么?
SICP source code scheme
(define (expand num den radix)
(cons-stream
(quotient (* num radix) den)
(expand (remainder (* num radix) den)
den
radix))) 我的笔记 自动保存