assign - 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


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

 


Download Help Document