【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


目录
相关文章
|
Go
【SICP练习】146 练习4.2
版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/44729521 练习4-2 原文 Exercise 4.
670 0
|
数据安全/隐私保护