Computer-電腦與人生


Why is Lisp so great?

Monday, June 12th, 2006

自從看完了駭客與畫家後,就開始看Common Lisp相關的書和文章。其中我最有興趣的是Paul Graham不斷提起的macro。

一開始我還不了解macro到底強在哪裡,為什麼能讓Lisp如此特別,直到發現Why is Lisp so great? or Why so many parenthesis?這篇文章,才大大一驚,原來macro是這樣玩的!

這篇文章舉了Haskell著名的quicksort implementation為例

qsort []     = []
qsort (x:xs) = qsort elts_lt_x ++ [x] ++ qsort elts_greq_x
                 where
                   elts_lt_x   = [y | y < - xs, y < x]
                   elts_greq_x = [y | y <- xs, y >= x]

這份實做真的非常漂亮,短短幾行就說完了qsort。
但如果用原始的Lisp語法寫起來還蠻複雜的,因為Lisp沒有提供list comprehension(Haskell的中括號)這種特殊的簡潔語法。但透過macro,就可以自己幫Lisp加上新的語法,而且完全不用動到compiler。

(defun qsort (ax)
  (and ax
       (let ((a (car ax))
             (x (cdr ax)))
         (append (qsort [y (y < - x) (< y a)])   ; A
                 (list a)          ; B
                 (qsort [y (y <- x) (>= y a)])))))   ; C

多麼神奇的特色啊,也難怪Lisp可以活這麼久而且永遠有許多死忠支持者..。

Google Browser Sync

Thursday, June 8th, 2006


Google又有新東西了,這次是Google Browser Sync

它是一個firefox extension,可以全自動sync不同電腦間的browser設定,包括bookmark, history, cookie, saved password(註), 甚至可以把目前看的所有tabs存下來,再到另一台電腦打開..。

註.
連saved password都要放到google上,真是有點恐怖。雖然它號稱會用你的PIN code加密過,但真的能這麼放心的把密碼也交給google嗎?

Google Notebook

Tuesday, May 16th, 2006

http://www.google.com/notebook/

Google又有新東西啦,這次是notebook。還是只支援IE和Firefox,不支援Safari,而且也不能作中文search @_@

搭配它的Firefox extension還不錯用,可以很方便記錄網頁上的資料。
看來有機會讓我改掉用BBS作記錄的習慣…

Vim7嘗鮮

Wednesday, May 10th, 2006

剛發現Debian的experimental pool中其實已經有vim 7.0 beta了,所以就裝來玩玩了。 為了用tab page,還得設一些新的key binding。 很多人都用Ctrl-T來開tab,但ctrl-t在trace code時很常用,所以我只好mapping到別的鍵了。

map tl :tabnext
map th :tabprev

map tn :tabnew

map td :tabclose

另外,設定cursorline和cursorcolumn兩個option可以使游標所在的行、列高亮度顯示出來。設定spell可以開啟新的spell checking功能。

Vim7

Wednesday, May 10th, 2006

Vim7正式推出了,以下是官方公佈的一些新功能:

  • Spell checking support for about 50 languages
  • Intelligent completion for C, HTML, Ruby, Python, PHP, etc.
  • Tab pages, each containing multiple windows
  • Undo branches: never accidentally lose text again
  • Vim script supports Lists and Dictionaries (similar to Python)
  • Vim script profiling
  • Improved Unicode support
  • Highlighting of cursor line, cursor column and matching braces
  • Translated manual pages support.
  • Internal grep; works on all platforms, searches compressed files
  • Browsing remote directories, zip and tar archives
  • Printing multibyte text

因為debian還沒有推出正式的package,我也就還沒試用。但從上面看來,我最期待的就是tab page, undo branches了 :-D