Bind Labels - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


DataSeries/with

simplify syntax for referring to DataSeries values

DataSeries/unwith

remove DataSeries values from global namespace

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

with(DS)

unwith(DS)

Parameters

DS

-

a DataSeries object

Description

• 

The with command, applied to a DataSeries object, makes values of the DataSeries available as variables at the interactive level.

• 

The unwith command undoes the effects of prior calls to with.

• 

The with command is effective only at the top level, and intended primarily for interactive use.  Because with operates by using lexical scoping, it does not work inside the bodies of procedures, module definitions, or within statements.  See the Examples section.

• 

DataSeries are collections of labeled values of data. They are explained in more detail on the DataSeries help page.

• 

Only value labels that are symbols can be used as variables. Values with labels that are not symbols (for example, indexed names or other algebraic expressions) are ignored by with.

• 

When with is called with a DataSeries as its argument, it binds the value names of the DataSeries to the global namespace.  This makes the value names available to the interactive user at the top level of the Maple interaction loop.

• 

The unwith command undoes the effects of prior calls to with. That is, when it is called with as its argument a DataSeries that was previously submitted to with, unwith unbinds the value names in the global namespace, any previous bindings of those names are restored.

• 

The restart command clears the Maple internal memory, clearing any bindings made by with.

• 

The with command is also used for making the exports of a package accessible in the global name space. This usage is explained on the with help page. This is different from using the command on a DataSeries object in several ways: the exports of a package are (typically) procedures, whereas the values in a DataSeries (typically) are not, for example.

Examples

If you have defined a DataSeries ds which has a value labeled a, then to access that value, you must enter ds[a].

dsDataSeries1,2,3,4,labels=a,b,c,d

dsa1b2c3d4

(1)

ds2DataSeries5,6,7,8,labels=a,c,e,g

ds2a5c6e7g8

(2)

dsa

1

(3)

a

a

(4)

However, after using the with(ds) command, you can use the label a directly, without specifying the DataSeries to which the value belongs.

withds

a,b,c,d

(5)

a

1

(6)

unwithds

a

a

(7)

As illustrated in the previous example, a list of the DataSeries labels bound to the top level is returned by with.

Sometimes a label is identical to a top-level name with a global meaning. Global names are still fully accessible.  To access the global name a after having bound a DataSeries that has a label a, use the prefix form of the : operator, as in  :a .

For example, the variable a may be in use.

a12.3

a12.3

(8)

After issuing a call to with(ds), in which the name a occurs as a label, the name a now refers to the value corresponding to that label. The original variable is still available by using the syntax :-a.

withds

a,b,c,d

(9)

a

1

(10)

:-a

12.3

(11)

In addition, two or more DataSeries may have values with some of the same names. In this case, if both are bound using with, only the most recently bound value will be available at the top level by using a single variable name. In the following example, that is ds2.

withds2

a,c,e,g

(12)

a

5

(13)

You can still refer to a value of any other DataSeries by naming the DataSeries it comes from, using syntax of the form ds[':-a']. If you were to write just ds[a], then the variable a would first evaluate to the corresponding value of ds2, and ds cannot infer which value is meant. This results in an error message. Using the syntax :-a makes sure that the global name a is used, not the value name from ds2. In this case, that global name was assigned a value (namely, 12.3); we do not want :-a to evaluate to that value either: if it would, then ds could still not infer which value is meant. In order to prevent :-a from evaluating, we use unevaluation quotes.

dsa

Error, (in DataSeries:-`?[]`) invalid row index (5) into DataSeries with 4 rows

ds:-a

Error, (in DataSeries:-`?[]`) invalid index 12.3 into DataSeries

ds:-a

1

(14)

Compatibility

• 

The DataSeries/with and DataSeries/unwith commands were introduced in Maple 2016.

• 

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

See Also

DataFrame,with

DataSeries

DataSeries/Constructor

with