糯米

TI DaVinci, gstreamer, ffmpeg
随笔 - 167, 文章 - 0, 评论 - 47, 引用 - 0
数据加载中……

lisp find find-if find-if-not

find item sequence &key from-end test test-not start end key => element

find-if predicate sequence &key from-end start end key => element

find-if-not predicate sequence &key from-end start end key => element

Arguments and Values:

item---an object.

sequence---a proper sequence.

predicate---a designator for a function of one argument that returns a generalized boolean.
接受一个参数的函数,返回boolean

from-end---a generalized boolean. The default is false.
boolean类型,默认为false

test---a designator for a function of two arguments that returns a generalized boolean.
接受两个参数的函数,返回boolean

test-not---a designator for a function of two arguments that returns a generalized boolean.
接受两个参数的函数,返回boolean

startend---bounding index designators of sequence. The defaults for start and end are 0 and nil, respectively.

key---a designator for a function of one argument, or nil.

element---an element of the sequence, or nil.

findfind-if, and find-if-not each search for an element of the sequence bounded by start and end that satisfies the predicate predicate or that satisfies the test test or test-not, as appropriate.

If from-end is true, then the result is the rightmost element that satisfies the test.

If the sequence contains an element that satisfies the test, then the leftmost or rightmost sequence element, depending on from-end, is returned; otherwise nil is returned.


Examples:

Examples:
(find #\d "here are some letters that can be looked at" :test #'char>)
=> #\Space
(find-if #'oddp '(1 2 3 4 5) :end 3 :from-end t) => 3
(find-if-not #'complexp '#(3.5 2 #C(1.0 0.0) #C(0.0 1.0)) :start 2) => NIL

posted on 2011-08-19 22:04 糯米 阅读(437) 评论(0)  编辑 收藏 引用 所属分类: Lisp


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理