【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


目录
相关文章