83's

Top > Tags > CommonLisp

CommonLisp

タイトル一覧を表示 | 本文を表示

属性リストへのアクセス August 07, 2008 00:19

調べるのに少し手間取ったのでメモ。

Common Lispだと

(getf (list :a 1 :b 2 :c 3) :a)
;;=> 1

これのScheme版はget-keyword

(get-keyword :a (list :a 1 :b 2 :c 3))
;;=> 1

属性リストって書くの楽でいいよなぁ。他の言語でこんなのやると罪悪感みたいのがわくけど、 こっちは関数があるおかげで「使っていいんだ」っていう雰囲気。

letの束縛部 September 09, 2007 02:41

Scheme(Gauche)

gosh> (let (x y) (list x y))
*** ERROR: Compile Error: syntax-error: malformed let: (let (x y) (list x y))
"(stdin)":1:(let (x y) (list x y))

Common Lisp(clisp)

[1]> (let (x y) (list x y))
(NIL NIL)

へぇ。