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

Racket

Name: Anonymous 2012-09-25 13:28

there must be a better way to do this right


(define (factorial n)
    (define (iter n result)
        (if (= n 0)
            result
            (iter (- n 1) (* result n))))
    (iter n 1))

Name: Anonymous 2012-09-25 18:10

>>5
Now that we are talking about implementation details I would like to bring notice that the function would not produce a stack overflow when compiled with GCC and optimization on x86, the call instruction is nowhere to be found in the resulting object code it only uses jmp.

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