首页 > 其他 > 详细

【SICP练习】136 练习3.67

时间:2015-03-29 10:51:59      阅读:299      评论:0      收藏:0      [点我收藏+]

练习3-67

原文

Exercise 3.67. Modify the pairs procedure so that (pairs integers integers) will produce the stream of all pairs of integers (i,j) (without the condition i < j). Hint: You will need to mix in an additional stream.

代码

(define (all-pairs s t)
        (cons-stream 
                (list (stream-car s) (stream-car t))
                (interleave
                        (interleave
                                (stream-map (lambda (x) (list (stream-car s) x))
                                                        (stream-cdr t))
                                (all-pairs (stream-cdr s) (stream-cdr t)))
                        (stream-map (lambda (x) (list x (stream-car t)))
                                                (stream-cdr s)))))

【SICP练习】136 练习3.67

原文:http://blog.csdn.net/nomasp/article/details/44724675

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!