% Macro AND
Macro AND
and form* => result*
form - フォーム
result - 最後のformの評価の結果の値か、
シンボルのnilかt。
マクロandは、各formを左から右へひとつずつ評価します。
どれかのformの評価がnilを返却したとき、
andは残りのformを評価せず
すぐにnilを返却します。
もし最後以外の全てのformがtrueの値であれば、
andは、最後のformの評価によって生成された結果を返却します。
formがないときは、(and)はtを返却します。
(if (and (>= n 0)
(< n (length a-simple-vector))
(eq (elt a-simple-vector n) 'foo))
(princ "Foo!"))
上記の式は、もし提供されたnがa-simple-vectorへの有効なインデックスであり、
かつa-simple-vectorの要素nがシンボルfooのときはFoo!が印字されます。
andは、その部分が左から右へテストされることが保証されているので、
もしnが範囲外のときはeltが呼び出されません。
(setq temp1 1 temp2 1 temp3 1) => 1
(and (incf temp1) (incf temp2) (incf temp3)) => 2
(and (eql 2 temp1) (eql 2 temp2) (eql 2 temp3)) => true
(decf temp3) => 1
(and (decf temp1) (decf temp2) (eq temp3 'nil) (decf temp3)) => NIL
(and (eql temp1 temp2) (eql temp2 temp3)) => true
(and) => T
なし。
なし。
(and form) == (let () form)
(and form1 form2 ...) == (when form1 (and form2 ...))