17.05.2015 Views

zl:1 - FTP

zl:1 - FTP

zl:1 - FTP

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.

575 su bstitute-if<br />

For example:<br />

(substitute 'hi 'b '(b a b) :from-end t :count 1 )<br />

=> (8 A HI)<br />

Use the keyword arguments :start and :end to delimit the portion of the<br />

sequence to be operated on.<br />

:start and :end must be non-negative integer indices into the sequence.<br />

:start must be less than or equal to :end, else an error is signalled. It<br />

defaults to zero (the start of the sequence).<br />

:start indicates the start position for the operation within the sequence.<br />

:end indicates the position of the first element in the sequence beyond the<br />

end of the operation. It defaults to nil (the length of the sequence).<br />

If both :start and :end are omitted, the entire sequence is processed by<br />

default.<br />

For example:<br />

(substitute 'a 'b '(b a b) :start 1 :end 3) => (8 A A)<br />

(substitute 'a 'b '(b a b) :end 2) => (A A 8)<br />

(substitute 'a 'b '(b a b) :end 3) => (A A A)<br />

The :count argument, if specified, limits the number of elements altered.<br />

If more than :count elements satisfy the predicate, then only the leftmost<br />

:count elements are replaced.<br />

For example:<br />

(substitute 'a 'b '(b b a b b) :count 3) => (A A A A 8)<br />

I<br />

. The result of the substitute function can share cells with the argument sequence.<br />

A list can share a tail with an input list, and the result can be eq<br />

to the input sequence if no elements need to be changed.<br />

See the function subst, page 571.<br />

substitute is the non-destructive version of nsubstitute.<br />

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

Symbolics Common Lisp: Language Concepts.<br />

substitute-if newitem predicate sequence &key key from-end (start Function<br />

0) end count<br />

substitute-if returns a sequence of the same type as sequence that has the<br />

same elements, except that those in the subsequence delimited by :start<br />

and :end and satisfying predicate are replaced by newitem. This is a nondestructive<br />

operation, and the result is a copy of sequence with some elements<br />

changed.

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

Saved successfully!

Ooh no, something went wrong!