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 22:37

>>8
I'm sure my definition is common and I'm sure your code is redundant. Isn't it redundant when you prefer (define id (lambda (x) x)) to (define (id x) x)?

The point of lisp is to make the most use of its expressiveness, else you're crippling your code.

but I guess it would please >>6's PIG DISGUSTING sense of indentation.

Buttfuckinghurt.

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