Previous Page Next Page Contents

extop -- the operands of a domain element

Introduction

extop(object) returns all operands of the domain element object.

extop(object, i) returns the i-th operand.

extop(object, i..j) returns the i-th to j-th operand.

Call(s)

extop(object)
extop(object, i)
extop(object, i..j)

Parameters

object - an arbitrary MuPAD object
i, j - nonnegative integers

Returns

a sequence of operands or the specified operand. FAIL is returned if no corresponding operand exists.

Related Functions

DOM_DOMAIN, extnops, extsubsop, new, nops, op, subsop

Details

Example 1

We create a new domain d and use the function new to create an element of this type. Its internal data representation is the sequence of arguments passed to new:

>> d := newDomain("demo"): e := new(d, 1, 2, 3): extop(e)
                                  1, 2, 3

Individual operands can be selected:

>> extop(e, 2)
                                     2

Ranges of operands can be selected:

>> extop(e, 1..2)
                                   1, 2

The 0-th operand of a domain element is its domain:

>> extop(e, 0)
                                   demo
>> delete d, e:

Example 2

First, a new domain d is defined via newDomain. The "new" method serves for creating elements of this type. The internal representation of the domain is a sequence of all arguments of this "new" method:

>> d := newDomain("d"): d::new := () -> new(dom, args()):

The system's op function is overloaded by the following "op" method of this domain. It is to return the elements of a sorted copy of the internal data sequence. In the implementation of the "op" method, the function extop is used to access the internal data:

>> d::op := proc(x, i = null())
            local internalData;
            begin internalData := extop(x);
                  op(sort([internalData]), i)
            end_proc:

Due to this overloading, op returns different operands than extop:

>> e := d(3, 7, 1): op(e); extop(e)
                                  1, 3, 7
      
                                  3, 7, 1
>> delete d, e:

Example 3

For kernel data types such as sets, lists etc., extop always returns the same operands as op:

>> extop([a, b, c]) = op([a, b, c])
                           (a, b, c) = (a, b, c)

Expressions are of kernel data type DOM_EXPR, thus extop(sin(x), 0) is equivalent to op(sin(x), 0):

>> domtype(sin(x)), extop(sin(x), 0) = op(sin(x), 0)
                            DOM_EXPR, sin = sin

Expression sequences are not flattened:

>> extop((1, 2, 3), 0), extop((1, 2, 3))
                             _exprseq, 1, 2, 3

Example 4

Non-existing operands are returned as FAIL:

>> extop([1, 2], 4),  extop([1, 2], 1..4)
                                FAIL, FAIL

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000