SHARE
TWEET

Untitled

a guest Nov 17th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (define pi1-stream
  2.   (lambda (S)
  3.     (letrec ((helper
  4.               (lambda (l)
  5.                 (if (stream-empty? l)
  6.                     empty-stream
  7.                     (stream-cons (stream-first l)
  8.                                  (helper (stream-filter
  9.                                           (lambda (x) (not (equal? x (stream-first l))))
  10.                                           (stream-rest l))))))))
  11.       (helper (stream-map (lambda (x) (stream-first x)) S)))))
  12.  
  13. (define pi2-stream
  14.   (lambda (S)
  15.     (letrec ((helper
  16.               (lambda (l)
  17.                 (if (stream-empty? l)
  18.                     empty-stream
  19.                     (stream-cons (stream-first l)
  20.                                  (helper (stream-filter
  21.                                           (lambda (x) (not (equal? x (stream-first l))))
  22.                                           (stream-rest l))))))))
  23.       (helper (stream-map (lambda (x) (stream-first (stream-rest x))) S)))))
  24.              
  25. (stream->listn (pi1-stream (cart-streams integers integers)) 10)
  26. (stream->listn (pi2-stream (cart-streams integers integers)) 10)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top