28.02.2014 Views

Burke_et_al-NIL_Reference_Manual_0286-1984

Burke_et_al-NIL_Reference_Manual_0286-1984

Burke_et_al-NIL_Reference_Manual_0286-1984

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Condition<strong>al</strong>s 28 Nil. Manued<br />

5.4 Condition<strong>al</strong>s<br />

1 f predicate cOllsequel1l [else/omlJ<br />

not x<br />

if ev<strong>al</strong>uates predicate. If the result is not f<strong>al</strong>se (i.e.. nO( nil). then the result of the if is<br />

the rcsult of ev<strong>al</strong>uating cOlJsequent. Otherwisc. jf· else/onn is specified. the result of thc if<br />

is the result ofevaJuating else/onn. otherwise nil.<br />

not is used )ogic<strong>al</strong>1y (0 invert the scnsc. of a predicatc. That is. it is byconvCnlion used<br />

to test for the object representing boo/ran jill.')£'. Because of the emply-list/booJean-faJse<br />

du<strong>al</strong>ity of the symhol nit. iris function<strong>al</strong>ly equhHlcnt to nuft (page 18). which logic<strong>al</strong>ly<br />

checks fbr the CIIII'I)' /isl which is represented by thc type named nult Thus. one ottcn<br />

sees c()nstruct~ of the thml<br />

( i f (n 0 t (n u 1·1 1» ('()f1scqU(,111 r/sejiJn1l)<br />

because nuff is used to check for empty-listness (fbr instance. being m the end of an<br />

iter<strong>al</strong>iun down a list). and the not is used to invert the sense. so that the cOllsequcllt will<br />

be nm if there is in facl som<strong>et</strong>hing left to the list l.<br />

cond {(prctiicllir {collsequent}-»-<br />

GenemJ historic<strong>al</strong> condo Each predic<strong>al</strong>r to the cond is ev<strong>al</strong>uated. in order. If the result<br />

of an ev<strong>al</strong>uation is f<strong>al</strong>se. then the cond ev<strong>al</strong>uates the corresponding consequents in that<br />

"clausc", r<strong>et</strong>urning as its v<strong>al</strong>ue the vatuc(s) of the last one. unless there were no<br />

consequents. in which case the v<strong>al</strong>ue of the cond is the v<strong>al</strong>ue of the predicl1le ev<strong>al</strong>uation.<br />

\ ..... It... \,....~. ,<br />

I"",",. 1 .. 1 ,.1\<br />

(p2 c2)<br />

(t e»<br />

is equiv<strong>al</strong>ent to<br />

( if pI cl<br />

(if p2 cl e»<br />

however cond <strong>al</strong>10ws multiple consequents. and <strong>al</strong>so may more clearly show the selection<br />

by clearly listing the sequenti<strong>al</strong>ly processed tests.<br />

If a11 of the predicates are f<strong>al</strong>se. then cond r<strong>et</strong>urns nil.<br />

when predic<strong>al</strong>e-/onn {consequent-form}­<br />

(when predicate-form<br />

consequent-J<br />

consequent-2<br />

cOllsequent-n)<br />

==><br />

(cond (predicate-form<br />

consequent-J<br />

consequent-]<br />

cOl1scquelll-n) )<br />

If predicQte-/onn ev<strong>al</strong>uates non-nuU. then the cOllsequl'llt-jOnns are eva1uated in order and<br />

the v<strong>al</strong>uc(s) of the last one r<strong>et</strong>urned as the v<strong>al</strong>ue of the when fonn: otherwise. the when<br />

fonn r<strong>et</strong>urns nit<br />

MC:NfLMAN:PCONS 81<br />

23-DEC-83

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!