17.05.2015 Views

zl:1 - FTP

zl:1 - FTP

zl:1 - FTP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

471<br />

selectq-every<br />

(let «x 'Bird»<br />

(<strong>zl</strong>:selectq x<br />

(foo (do-this»<br />

(bar (do-that»<br />

«baz quux mum) (do-the-other-thing»<br />

(otherwise (<strong>zl</strong>:ferror nil "Hey there, never heard of -5" x»»<br />

=> Error: Hey there, never heard of BIRO<br />

is equivalent to:<br />

(let «x 'Bird»<br />

(cond «eq x 'foo) (do-this»<br />

«eq x 'bar) (do-that»<br />

«<strong>zl</strong>:memq x '(baz quux mum» (do-the-other-thing»<br />

(t (<strong>zl</strong>:ferror nil "Hey there, never heard of -5" x»»<br />

=> Error: Hey there, never heard of BIRO<br />

For a table of related items: See the section "Conditional Functions" in<br />

Symbolics Common Lisp: Language Concepts.<br />

I<br />

selectq-every obj &body clauses Special Form<br />

A 'conditional that chooses one of its clauses to execute by comparing the<br />

value of a form against various constants, which are typically keyword sym- ",<br />

boIs. I ts form is as follows:<br />

(sel ectq-every key-form<br />

(test consequent consequent ... )<br />

(test consequent consequent ... )<br />

(test consequent consequent ... )<br />

... )<br />

The Irrst thing selectq-every does is to evaluate key-form; call the resulting<br />

value key. Then selectq-every considers each of the clauses in turn.<br />

If key matches the clause's test, the consequents of this clause are<br />

evaluated, and selectq-every returns the value of the last consequent. If<br />

there are no matches, selectq-every returns nil.<br />

A test can be any of the following:<br />

A symbol<br />

A number<br />

A list<br />

t or otherwise<br />

If the key is eq to the symbol, it matches.<br />

If the key is eq to the number, it matches. Only small<br />

numbers (integers) work.<br />

If the key is eq to one of the elements of the list, then it<br />

matches. The elements of the list should be symbols or<br />

integers.<br />

The symbols t and otherwise are special keywords that<br />

match anything. Either symbol can be used; t is mainly

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

Saved successfully!

Ooh no, something went wrong!