contains - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


List.contains

test for membership in the List

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

boolean contains( Object value )

Parameters

value

-

object to check

Description

• 

The contains function returns true if value is an element in the collection corresponding to the List and false otherwise.

• 

This is similar to member except that it accepts an arbitrary Object and does not throw a MapleException.

Examples

import com.maplesoft.openmaple.*;

import com.maplesoft.externalcall.MapleException;

class Example

{

    public static void main( String notused[] ) throws MapleException

    {

        String[] mapleArgs = { "java" };

        Engine engine = new Engine( mapleArgs, new EngineCallBacksDefault(), null, null );

        List s = (List)engine.evaluate( "[2,5,sin(x),1+2*x+x^2,7.5];" );

        System.out.println( "Is 2 in the list: " + ind.contains( engine.newNumeric( 2 ) ) );

        System.out.println( "Is 7 in the list: " + ind.contains( engine.newNumeric( 7 ) ) );

    }

}

Executing this code produces the following output:

Is 2 in the list: true

Is 3 in the list: false

See Also

ExternalCalling/Java/MapleException

OpenMaple

OpenMaple/Java/Algebraic

OpenMaple/Java/API

OpenMaple/Java/List

OpenMaple/Java/List/assign

OpenMaple/Java/List/containsAll

OpenMaple/Java/List/select