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

Continued Fractions

Name: Anonymous 2007-09-03 14:57 ID:Yg9/l8CK

(defun continued-fraction (real)
  (multiple-value-bind (integer-part fractional-part)
      (floor (rationalize real))
    (cons integer-part (if (zerop fractional-part)
               nil
               (continued-fraction (/ 1 fractional-part))))))

What does /prog/ think? Am I shooting myself in the foot by just throwing rationalize in there and hoping it works out?

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