select - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


Table.select

access the element associated with a key

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Algebraic select( Algebraic key ) throws MapleException

Parameters

key

-

index of the element to access

Description

• 

The select function retrieves the Algebraic object associated with key in the Table. If no element is associated with key, an error is raised.

• 

To check whether an element is associated with key, use the has function.

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

        Table t = (Table)engine.evaluate( "table([(1)=100,(2)=200,(3)=300,(4)=400]):" );

        System.out.println( t.select( engine.newNumeric( 1 ) ) );

        System.out.println( t.select( engine.newNumeric( 2 ) ) );

        System.out.println( t.select( engine.newNumeric( 3 ) ) );

        try {

            t.select( engine.newNumeric( 10 ) );

        } catch ( MapleException me ) {

            System.out.println( me.getMessage() );

        }

    }

}

Executing this code produces the following output.

100

200

300

No such key in table

See Also

ExternalCalling/Java/MapleException

OpenMaple

OpenMaple/Java/Algebraic

OpenMaple/Java/API

OpenMaple/Java/Table

OpenMaple/Java/Table/assign

OpenMaple/Java/Table/has

OpenMaple/Java/Table/remove