<< Previous exercise (3.57) | Index | Next exercise (3.59) >>
meteorgan
The result is the rational value that num divide den in base radix. (expand 1 7 10) => 1 4 2 8 5 7 4 2 8 5 7 ... (expand 3 8 10) => 3 7 5 0 0 0 ...
danhuynh
I think @meteorgan miscalculate (expand 1 7 10). => 1 4 2 8 5 7 1 4 2 8 5 7 ...
j-minster
edit: I noticed meteorgan's sequence is missing a '1', so danhuynh is correct.
(map (lambda (s) (stream-ref (expand-rad 1 7 10) s)) '(0 1 2 3 4 5 6 7 8 9 10)) ;=> (1 4 2 8 5 7 1 4 2 8 5)
xdavidliu
The result is the floating-point representation of (/ num den) with radix as the base.
;; list of first n elements of stream (define (partial-stream->list stream n) (define (rec str i) (if (= i n) () (cons (stream-car str) (rec (stream-cdr str) (1+ i))))) (rec stream 0)) (partial-stream->list (expand 1 7 10) 10) ;Value: (1 4 2 8 5 7 1 4 2 8) (/ 1.0 7) ;Value: .14285714285714285 (partial-stream->list (expand 3 8 10) 5) ;Value: (3 7 5 0 0) (/ 3.0 8) ;Value: .375
danhuynh
I think @meteorgan miscalculate (expand 1 7 10). => 1 4 2 8 5 7 1 4 2 8 5 7 ...
j-minster
edit: I noticed meteorgan's sequence is missing a '1', so danhuynh is correct.
xdavidliu
The result is the floating-point representation of (/ num den) with radix as the base.