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

n C r

Name: Anonymous 2009-05-24 17:51

(define combination
  (λ(n k)
    (let ((stalled-factorial
           (λ(N stop-value)
             (define iter-sf
               (λ(accum N stop-value)
                 (if (= N stop-value)
                     accum
                     (iter-sf (* accum N) (- N 1) stop-value))))
             (iter-sf 1 N stop-value))))
      (if (> k (- n k))
          (/ (stalled-factorial n k) (factorial (- n k)))
          (/ (stalled-factorial n (- n k)) (factorial k))))))

Name: Anonymous 2009-05-24 21:30

private static final double[] facts
ENTERPRISE QUALITY

Is it just me, or does LISP make everything 10x longer and harder to write?
Actually the original is very short but makes unnecessary intermediate calculations like >>4 . When I was trying to calculate 20000C10000 it was taking too many precious seconds and I had to OPTIMIZE it.

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