【SICP练习】136 练习3.67

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


版权声明:本文为 NoMasp柯于旺 原创文章,如需转载请联系本人。

posted @ 2015-03-29 10:04  nomasp  阅读(102)  评论(0编辑  收藏  举报