Advertisement
Jobjob

Programmation déclarative - Q3A - 06/2012

Jan 4th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.44 KB | None | 0 0
  1. (define (exact->stream q)
  2.   (let
  3.       ((first-decimal (lambda (x)
  4.                         (truncate (* x 10))
  5.                         )
  6.                       )
  7.        )
  8.     (let*
  9.         ((inexact (exact->inexact q))
  10.          (g (- inexact (truncate inexact)))
  11.          (first (first-decimal g)))
  12.       (if (= first 0)
  13.           '()
  14.           (cons-stream (inexact->exact first) (exact->stream (* g 10)))
  15.           )
  16.       )
  17.     )
  18.   )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement