Set Class - 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


Set

OpenMaple representation of a set

 

Description

Method Summary

Examples

Compatibility

Description

• 

The com.maplesoft.openmaple.Set class represents a Maple set.

• 

To create a Set, invoke the toSet method on any Indexable object or cast the result of an evaluate call to Set.

• 

The Set class implements the java.util.Set interface on type Algebraic.

Method Summary

• 

The following methods are defined on Set objects,

• 

Note that Set publicly inherits from Indexable; therefore, it provides all the member functions from the Indexable and Algebraic classes in addition to those listed here.

Algebraic select( int i ) throws MapleException

• 

select returns the element at index i of the set.

• 

The Set class also includes the following methods which implement the java.util.Set interface:

boolean contains( Object value )

• 

contains returns true if value is an Algebraic and the Set contains a value identical to value.

  

This is similar to member except that it accepts an arbitrary Object and does not throw a MapleException.

boolean containsAll( Collection<?> o )

• 

containsAll returns true if every member of the collection o is an Algebraic which is equal to some element of the Set.

java.util.Iterator<Algebraic> iterator()

• 

iterator returns an Iterator object which can be used to iterate over the elements of the Set.

Object[] toArray()

• 

toArray returns an array of objects corresponding to the elements of the Set.

T[] toArray( T[] a )

• 

toArray with an array argument returns an Array populated with the elements of the Set. The runtime type T of this array matches that of the input array a.

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 );

        Set s = (Set)engine.evaluate( "{1, 17, 37}:" );

        System.out.println("Size of set: " + s.numElements());

        for (Algebraic elem : s) {

            System.out.println("Element: " + elem);

        }

    }

}

Executing this code produces the following output.

Size of set: 3

Element: 1

Element: 17

Element: 37

Compatibility

• 

The Set command was introduced in Maple 2018.

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

• 

The Set command was updated in Maple 2020.

See Also

OpenMaple

OpenMaple/Java/Algebraic

OpenMaple/Java/API

OpenMaple/Java/Examples

OpenMaple/Java/Expseq

OpenMaple/Java/List

OpenMaple/Java/Table

set

 


Download Help Document