2008-04-10

cutで記述量を減らす

SRFI-26で定義されているcutを使うと、記述量を減らせて楽。簡単な例を挙げると、

(cond ((#/post-(.+)$/ "tag:blogger.com,1999:blog-blogID.post-postID") =>
       (lambda (m) (m 1))))

というのが、

(cond ((#/post-(.+)$/ "tag:blogger.com,1999:blog-blogID.post-postID") =>
       (cut <> 1)))

と書けたりする。些細な違いかもしれないけど、lambdaなんていくらでも使うものだし、塵が積もって山になる……かもしれない。

0 件のコメント: