ListTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Tables, lists, and sets : ListTools Package : ListTools/Search

ListTools

  

Search

  

search for an occurrence of an element in a list

  

SearchAll

  

search for all occurrences of an element in a list

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Search( element, L )

SearchAll( element, L )

Parameters

element

-

expression

L

-

list

Description

• 

The Search(element, L) calling sequence searches for element in the list L. If element does not occur as an element of L, then 0 is returned. Otherwise, the index of the first occurrence of element in L is returned.

  

Note: The list L is not assumed to be sorted, so the time taken by this procedure may be linear in the length of the list.

• 

The SearchAll(element, L) calling sequence finds all occurrences of element in L. It returns an expression sequence of the indices of occurrences of element in L. This expression sequence is NULL if element does not occur in L.

• 

In order to search for elements satisfying a certain predicate, use SelectFirst.

Examples

withListTools:

Searchu,a,u,v,b

2

(1)

Search2,5,4,2.2,3893,2,1,0,2,a

5

(2)

SearchAll2,5,4,2.2,3893,2,1,0,2,a

5,8

(3)

SearchAll1,2,3,4,5,6,7,8

See Also

ListTools

ListTools[BinarySearch]

ListTools[SelectFirst]

StringTools[Search]

StringTools[SearchAll]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam