Scheme

(define pp (lambda (x)
    (if (= x 0)  0 (+ x (pp (- x 1))))
))

关注下Scheme语言。一直听说函数式语言如何如何,今天去见识一下
用的DrScheme。感觉比MIT的那个方便。
上面是个1加到x的程序,对应的C程序是
int pp(int x){
    if(x==0)
        return 0;
    else
        return x+pp(x-1)
}
可能这个程序太简单,还没能体现出函数式语言的优势。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.