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

Factorial

Name: Anonymous 2010-11-23 2:58

Recursive Factorial:
cpu time: 5700 real time: 5699 gc time: 4731
Iterative Factorial:
cpu time: 1463 real time: 1459 gc time: 404
Π:
cpu time: 1263 real time: 1262 gc time: 351


Typed Racket:
Recursive Factorial:
cpu time: 3606 real time: 3607 gc time: 2655
Iterative Factorial:
cpu time: 1334 real time: 1334 gc time: 290
Π:
cpu time: 1190 real time: 1191 gc time: 269

Name: Anonymous 2010-11-23 3:06

Π:?

Name: Anonymous 2010-11-23 3:13

Name: Anonymous 2010-11-23 3:53

>>3 I thought about it but
(Π 1 10000)
. . reference to an identifier before its definition: |Π|

nothing in docs except for dot-products shit.

IHBT

Name: Anonymous 2010-11-23 4:28

>>4
(Π 1 10000)
That's because you're a faggot.
(define Π
  (λ (f n m)
    (let loop ((i n)
               (x 1))
      (if (> i m) x
          (loop (+ i 1)
                (* x (f i)))))))
(define I
  (λ (x) x))

(time (let loop ((i 0))
    (when (< i 10)
      (Π I 1 10000)
      (loop (add1 i)))))

Name: Anonymous 2010-11-23 5:25

>>5
(define Π (λ (a b) (/ (fact b) (fact a))))

Name: Anonymous 2010-11-23 5:39

>>6
Mine is OMG OPTIMISED.
Also, Π should take a function to be applied before every multiplication.

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