Drake's Weblog

1 minute read

逛了一下約耳的網站,看到這一篇測測你自己,裏頭的題目是這樣的:

(MIT-Scheme) 使用以下函數

(define (accumulate combiner null-value l)
   (if (null? l)
       null-value
       (combiner (car l)
                 (accumulate combiner
                             null-value
                             (cdr l)))))

實作平方和, 就是計算一串數字平方的加總,例如

(sum-of-squares '(1 2 3 4 5))

應為55.

直接在 lis.py 裏頭試一下,試了好幾分鐘,總算…

PS. Emacs + SLIME 已經夠不好用了,lis.py 更不好用 = =

Likely: 用 Python 寫一個精簡的 Lisp Interpreter.

    • None
comments powered by Disqus

Recent posts

Categories

About

You're looking at Drake's words or statements. All opinions are my own.