【SICP练习】138 练习3.69

练习3-69

原文

这里写图片描述

代码


(define (triples s t u)
  (cons-stream (list
        (stream-car s)
        (stream-car t)
        (stream-car u))
           (interleave
        (stream-map (lambda (x) (cons (stream-car s) x))
                (stream-cdr (pairs t u)))
        (triples (stream-cdr s)
             (stream-cdr t)
             (stream-cdr u)))))
;Value: triples

(define (phythagorean-numbers)
  (define (square x) (* x x))
  (define numbers (triles integers integers integers))
  (stream-filter (lambda (x)
           (= (square (caddr x))
              (+ (square (car x)) (square (cadr x)))))
         numbers))
;Value: phythagorean-numbers



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


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


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

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