【SICP练习】136 练习3.67

来源:互联网 发布:jdbc连接数据库代码 编辑:程序博客网 时间:2024/05/29 06:29

练习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)))))



感谢您的访问,希望对您有所帮助。 欢迎大家关注或收藏、评论或点赞。


为使本文得到斧正和提问,转载请注明出处:
http://blog.csdn.net/nomasp


5 0
原创粉丝点击