List.indexByRange - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

List.indexByRange

return a sublist of the list

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

void indexByRange( int a, int b ) throws MapleException

Parameters

a

-

index of the beginning of the range

b

-

index of the end of the range

Description

• 

The indexByRange function returns a List object corresponding to the sublist from positions a to b inclusive.

• 

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

• 

The input indices are one-based; that is, the index of the first element is 1 and the index of the last element equals the result of numElements. See subList for an equivalent which is zero-based.

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( "[2,4,6,8,10]:" );

        List l2 = l.indexByRange( 2, 4 );

        System.out.prinln( "Sublist: " + l2 );

    }

}

Executing this code produces the following output.

[4, 6, 8]

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

OpenMaple/Java/List/subList