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.

219<br />

find<br />

(loop for n in 1<br />

sum n into the-sum<br />

count t into the-count<br />

finally (return (quotient the-sum the-count»)<br />

is a list<br />

(defun sum-series (limit)<br />

(loop for num from 8 to limit<br />

with sum-of-series = 8<br />

initially (print "The sum of this series is :")<br />

do<br />

(setq sum-of-series (+ sum-of-series num»<br />

finally (prin1 sum-of-series») => SUM-SERIES<br />

(sum-series 9) =><br />

"The sum of this series is :" 45<br />

NIL<br />

(defun over-the-top (num)<br />

(loop for i from 1 to 18<br />

when (= i num) return<br />

finally (print "Finally triggered"») => OVER-THE-TOP<br />

(over-the-top 5) => 5<br />

(over-the-top 28) =><br />

"Finally triggered" NIL<br />

See the macro loop, page 309.<br />

find item sequence &key (test #'eql) test-not (key #'identity) Function<br />

from-end (start 0) end<br />

If sequence contains an element satisfying the predicate specified by the<br />

:test keyword argument, then the leftmost such element is returned; otherwise<br />

nil is returned.<br />

item is matched against the elements specified by the test keyword. The<br />

item can be any Symbolics Common Lisp object.<br />

sequence can be either a list or a vector (one-dimensional array). Note that<br />

nil is considered to be a sequence, of length zero.<br />

:test specifies the test to be performed. An element of sequence satisfies<br />

the test if (funcall testfun item (keyfn x» is true. Where testfun is the test<br />

function specified by :test, keyfn is the function specified by :key and x is<br />

an element of the sequence. The default test is eql.<br />

:test-not is similar to :test, except that the sense of the test is inverted.<br />

An element of sequence satisfies the test if (funcall testfun item (keyfn x»<br />

is false.<br />

I

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

Saved successfully!

Ooh no, something went wrong!