add an entry into the Maple Table - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : OpenMaple : Java Application Programming Interface : Table Class : OpenMaple/Java/Table/assign

Table.assign - add an entry into the Maple Table

Calling Sequence

void assign( Algebraic key, Algebraic val ) throws MapleException

Parameters

key

-

index to associate with the value

val

-

value to assign into the table

Description

• 

The assign function associates the Algebraic object val with the Algebraic index key in the Table.

• 

If a value is already assigned to the index key, it is overwritten by val.

Examples

import com.maplesoft.openmaple.*;

import com.maplesoft.externalcall.MapleException;

class Example

{

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

    {

    String mapleArgs[];

    Engine engine;

    Table t;

    mapleArgs = new String[1];

    mapleArgs[0] = "java";

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

        null, null );

    t = engine.newTable();

    System.out.println( t );

    t.assign( engine.newNumeric( 1 ),

            engine.newNumeric( 100 ) );

    t.assign( engine.newNumeric( 2 ),

            engine.newNumeric( 200 ) );

    t.assign( engine.newNumeric( 3 ),

            engine.newNumeric( 300 ) );

    t.assign( engine.newNumeric( 4 ),

            engine.newNumeric( 400 ) );

    System.out.println( t );

    t.assign( engine.newNumeric( 3 ),

            engine.newNumeric( 600 ) );

    t.assign( engine.newNumeric( 4 ),

            engine.newNumeric( 800 ) );

    System.out.println( t );

    }

}

Executing this code produces the following output.

table([])

table([(1)=100,(2)=200,(3)=300,(4)=400])

table([(1)=100,(2)=200,(3)=600,(4)=800])

See Also

ExternalCalling/Java/MapleException, OpenMaple, OpenMaple/Java/Algebraic, OpenMaple/Java/API, OpenMaple/Java/Table, OpenMaple/Java/Table/has, OpenMaple/Java/Table/remove, OpenMaple/Java/Table/select


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