List.assign - assign a value to an element of the list
|
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 where is the length of the list. The length can be obtained by calling length.
|
|
|
Examples
|
|
import com.maplesoft.openmaple.*;
|
import com.maplesoft.externalcall.MapleException;
|
class Example
|
{
|
public static void main( String notused[] ) throws MapleException
|
{
|
String mapleArgs[];
|
Engine engine;
|
List l;
|
mapleArgs = new String[1];
|
mapleArgs[0] = "java";
|
engine = new Engine( mapleArgs, new EngineCallBacksDefault(),
|
null, null );
|
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]
|
|
|
|
|
Download Help Document
Was this information helpful?