Previous Page Next Page Contents

extsubsop -- substitute operands of a domain element

Introduction

extsubsop(d, i = new) returns a copy of the domain element d with the i-th operand of the internal representation replaced by new.

Call(s)

extsubsop(d, i1 = new1, i2 = new2...)

Parameters

d - an element of a library domain
i1, i2... - nonnegative integers
new1, new2... - arbitrary MuPAD objects

Returns

the input object with replaced operands.

Related Functions

DOM_DOMAIN, extnops, extop, new, nops, op, subs, subsex, subsop

Details

Example 1

We create a domain element and then replace its first operand:

>> d := newDomain("1st"): e := new(d, 1, 2, 3): extsubsop(e, 1 = 5)
                             new(1st, 5, 2, 3)

This does not change the value of e:

>> e
                             new(1st, 1, 2, 3)
>> delete d, e:

Example 2

The domain type of an element can be changed by replacing its 0-th operand:

>> d := newDomain("some_domain"): e := new(d, 2): 
   extsubsop(e, 0 = Dom::IntegerMod(5))
                                  2 mod 5
>> delete d, e:

Example 3

We substitute the sixth operand of a domain element that has less than six operands. In such cases, an appropriate number of NIL's is inserted:

>> d := newDomain("example"): e := new(d, 1, 2, 3, 4):
   extsubsop(e, 6 = 8)
                     new(example, 1, 2, 3, 4, NIL, 8)
>> delete d, e:

Example 4

We substitute the first operand of a domain element e by a sequence with three elements. These become the first three operands of the result; the second operand of e becomes the fourth operand of the result, and so on. This new numbering is already in effect when the second substitution is carried out:

>> d := newDomain("example"): e := new(d, 1, 2, 3, 4):
   extsubsop(e, 1 = (11, 13, 17), 2 = (29, 99))
                   new(example, 11, 29, 99, 17, 2, 3, 4)
>> delete d, e:

Example 5

We define a domain with its own evaluation method. This method prints out its argument such that we can see whether it is called. Then we define an element of our domain.

>> d := newDomain("anotherExample"): 
   d::evaluate := x -> (print("Argument:", x); x):
   e := new(d, 3)
                          new(anotherExample, 3)

We can now watch all evaluations that happen: extsubsop evaluates its arguments, performs the desired substitution, but does not evaluate the result of the substitution:

>> extsubsop(e, 1 = 0)
                    "Argument:", new(anotherExample, 3)
      
                          new(anotherExample, 0)
>> delete d, e:

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000