std-position-if


Synopsis

(std-position-if <pred> <lst>)

Description

STD-POSITION-IF returns the first found position (index) the element which matches the predicate pred. pred is a function or lambda list accepting one argument and returning either nil or non-nil.

It returns either an integer number or nil if not found.

Examples

(std-position-if 'numberp '(0 1 2 3))      => 0
(std-position-if 'stringp '(0 "1" 2 "3"))  => 1
(std-position-if 
'(lambda (x)
(or (std-integerp x) (stringp x)))
'(nil 0 "1" 2 "3")) => 1

Arguments

pred: a function or lambda list accepting one argument and returning either nil or non-nil.

lst: any proper list.

Return Value

An integer number or nil.

Side Effects

Beware that the predicate pred may produce any side-effects.

Module

(std-require 'STDLIST)

Defined in STDLIST

#- SMALL