Indexable.toList
convert collection to a list
Indexable.toSet
convert collection to a set
Calling Sequence
Description
Examples
List toList() throws MapleException
Set toSet() throws MapleException
The toList function returns a List with the contents from the Indexable expression.
The toSet function returns a Set with the contents from the Indexable expression.
If toList is invoked when the current Indexable is already a list or toSet is invoked when the current Indexable is already a set, then a reference to the current object is returned.
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 );
Indexable ind = (Indexable)engine.evaluate( "{3,5,7,9,10}:" );
List l = ind.toList();
System.out.println( "Size of list result: " + l.numElements() );
ind = (Indexable)engine.evaluate( "table([a=3,b=7,c=9,d=3,e=13]):" );
Set s = ind.toSet();
System.out.println( "Size of set result: " + s.numElements() );
}
Executing this code produces the following output.
Size of list result: 5
Size of set result: 4
See Also
ExternalCalling/Java/MapleException
OpenMaple
OpenMaple/Java/Algebraic
OpenMaple/Java/API
OpenMaple/Java/Indexable
OpenMaple/Java/Indexable/max
OpenMaple/Java/Indexable/member
OpenMaple/Java/Indexable/min
OpenMaple/Java/Indexable/numElements
Download Help Document