List.assign - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

List.assign

assign a value to an element of the list

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

void assign( int i, Algebraic val ) throws MapleException

Parameters

i

-

index of the entry to assign

val

-

value to assign to the list

Description

• 

The assign function assigns the Algebraic object val into the element of the List indexed by i.

• 

The assign function can be called only on an List that is not a unique representation. For more information, see unique).

• 

Valid values of i are 1..n where n is the length of the list.  The length can be obtained by calling numElements.

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 l = (List)engine.evaluate( "[1,2,3]:" );

        try

        {

            l.assign( 1, engine.newNumeric( 2.2 ) );

        }

        catch ( MapleException me )

        {

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

        }

        l = engine.newList( 3 );

        l.assign( 1, engine.newNumeric( 1 ) );

        l.assign( 2, engine.newNumeric( 2 ) );

        l.assign( 3, engine.newNumeric( 3 ) );

        l = (List)l.unique();

        System.out.println( l );

    }

}

Executing this code produces the following output.

Error, lists from Maple cannot be modified in-place

[1, 2, 3]

See Also

ExternalCalling/Java/MapleException

OpenMaple

OpenMaple/Java/Algebraic

OpenMaple/Java/API

OpenMaple/Java/List

OpenMaple/Java/List/contains

OpenMaple/Java/List/containsAll

OpenMaple/Java/List/select