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

Online Help

All Products    Maple    MapleSim


Indexable.member

test for membership in the collection

 

Calling Sequence

Description

Examples

Calling Sequence

boolean member( Algebraic e ) throws MapleException

Description

• 

The member function returns true if e is an element in the collection corresponding to the Indexable and false otherwise.

• 

Note that member compares e against the values themselves, not against the indices (keys). If the collection is a Table, the has function may be used to test whether e is an index in the table.

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 );

        Indexable ind;

        ind = (Indexable)engine.evaluate( "[2,5,sin(x),exp(nu),7.5]:" );

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

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

        ind = (Indexable)engine.evaluate( "{3,7,9,11,13}:" );

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

        System.out.println( "Is 3 in the set: " + ind.member( engine.newNumeric( 3 ) ) );

        ind = (Indexable)engine.evaluate( "table([ 2 = 3, 4 = \"somestring\", 5 = Pi/2 ]):" );

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

        System.out.println( "Is 3 in the table: " + ind.member( engine.newNumeric( 3 ) ) );

        ind = (Indexable)engine.evaluate( "Array( 1..3, 1..3, (i,j)->(i*j)+1 ):" );

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

        System.out.println( "Is 3 in the Array: " + ind.member( engine.newNumeric( 3 ) ) );

    }

}

Executing this code produces the following output:

Is 2 in the list: true

Is 3 in the list: false

Is 2 in the set: false

Is 3 in the set: true

Is 2 in the table: false

Is 3 in the table: true

Is 2 in the Array: false

Is 3 in the Array: true

See Also

ExternalCalling/Java/MapleException

OpenMaple

OpenMaple/Java/Algebraic

OpenMaple/Java/API

OpenMaple/Java/Indexable

OpenMaple/Java/Indexable/max

OpenMaple/Java/Indexable/min

OpenMaple/Java/Indexable/numElements

OpenMaple/Java/Indexable/toList

OpenMaple/Java/Indexable/toSet