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

stack based languages

Name: Anonymous 2007-09-10 0:18 ID:JdAHaYKN

Hello, i am interested in learning a stack oriented language, so i started learning Forth. (from http://www.amresearch.com/starting_forth/)
Some alternatives i heard of are cat and factor.

What is best to learn from those? And suggest a good tutorial

Name: Anonymous 2007-09-10 6:48 ID:g2+im1Xr

>>8
That's almost as ugly as Perl. You want to calculate Fibonacci numbers, and you have to put up with the stack. The language model clearly gets in your way. You need to know Factor to understand these lines, yet I can't possibly think of a Fibonacci implementation that's not trivial in any other language:


(define (fib x)
        (if (< x 2)
            x
            (+ (fib (- x 1)) (fib (- x 2)))))

def fib(x):
    if x < 2: return x
    else:     return fib(x - 1) + fib(x - 2)

fib(x) = lambda x if x < 2 else fib(x - 1) + fib(x - 2)

unsinged int fib(unsigned int x) {
    return x < 2 ? x : fib(x - 1) + fib(x - 2)
}

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