Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Continued Fractions

Name: Anonymous 2009-05-29 20:56

(define collapse-cf
  (λ(rep)
    (let ((local-rep (reverse rep)))
      (define collapse
        (λ(accum x)
          (if (empty? (cdr x))
              (+ (car x) (/ 1 accum))
              (collapse (+ (car x) (/ 1 accum)) (cdr x)))))
      (collapse (car local-rep) (cdr local-rep))))))

The continued fraction of (1; 1) is the golden mean.

The continued fraction of (1; 2) is the square root of 2.

The continued fraction (88888888; 88888888) is just 88888888.

YOU CALL CARE

Name: Anonymous 2009-05-30 10:00

>>6
redundant
I do not think this word means what you think it means.
>>7
define form where a second let...
Would have to be letrec. I personally think it is clearer when let binds variables and defines bind functions because let-binding of complicated expressions looks like shit, but I guess it would please >>6's PIG DISGUSTING sense of indentation.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List