* xyzzy lisp : format ~{
- 繰り返し出力
- ~} で範囲を終了
- ~:} で範囲の終了を示したときは必ず1回は繰り返しを実行
- "{" リストを引数にとる
- ":{" リストを引数にとり、かつ繰り返し1回に1つのリストを消費
- "@{" 元のformatの引数をそのまま消費
- ":@{" 元のformatの引数をそのまま消費、かつ繰り返し1回に1つのリストを消費
- パラメータは1つ
- 繰り返し回数の上限
(format nil "~{~A ~}" '(a b c d)) "a b c d " (format nil "~:{~A ~}" '((a) (b) (c) (d))) "a b c d " (format nil "~@{~A ~}" 'a 'b 'c 'd) "a b c d " (format nil "~:@{~A ~}" '(a) '(b) '(c) '(d)) "a b c d " (format nil "~2{~A ~}" '(a b c d)) "a b " (format nil "~{~A ~}" nil) "" (format nil "~{~A ~:}" '(a)) ; nilが引数だとエラー "a " ; "~^"と一緒に使うのが便利 (format nil "~{~A~^, ~}~%" '(one two three four)) ; 最後に", "はいらない "one, two, three, four "
update : 2006-10-04 (Wed) 00:15:53