numElements - Maple Help

Indexable.numElements

return the number of elements in the collection

Indexable.size

return the size of the collection

 Calling Sequence int numElements( ) throws MapleException int size( )

Description

 • The numElements function returns the number of elements stored within the collection corresponding to the Indexable.
 • The size function behaves identically to numElements but does not throw a MapleException.

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 ); Indexable ind; ind = (Indexable)engine.evaluate( "[1,2,3,4]:" ); System.out.println( "Size of list: " + ind.numElements() ); ind = (Indexable)engine.evaluate( "{3,7,9,11,13}:" ); System.out.println( "Size of set: " + ind.numElements() ); ind = (Indexable)engine.evaluate( "table([ 2 = 3, 4 = \"somestring\", 5 = Pi/2 ]):" ); System.out.println( "Size of table: " + ind.numElements() ); ind = (Indexable)engine.evaluate( "Array( 1..3, 1..3, (i,j)->(i*j)+1 ):" ); System.out.println( "Size of Array: " + ind.numElements() ); ind = (Indexable)engine.evaluate( "Array( 10..30, 13..15, 11..17, (i,j)->(i*j)+1 ):" ); System.out.println( "Size of Array: " + ind.numElements() ); } }

Executing this code produces the following output:

 Size of list: 4 Size of set: 5 Size of table: 3 Size of Array: 9 Size of Array: 441