tablereverse - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Tables, lists, and sets : tablereverse

tablereverse

reverse table

 

Calling Sequence

Parameters

Options

Summary

Description

Examples

Compatibility

Calling Sequence

tablereverse(t, c, opts)

Parameters

t

-

table

c

-

(optional) combiner function

opts

-

zero or or more options as specified below

Options

• 

nolist = truefalse

  

Specifying 'nolist' or 'nolist'=true causes each entry in the output table s to be a simple collection of indices of t, without wrapping each index in a list. This is useful for tables where every index is a single object. When 'nolist' is used on a table with expression sequence indices or entries, the pairings may be difficult to deduce in the result.

• 

sort = truefalse

  

Specifying 'sort' or 'sort'=true indicates that each entry of the output table s should be sorted. This is only useful when a non-default combiner function c has been specified which produces ordered containers (for example a list or Array). The default value is false, which means that if the container type is ordered, the order chosen is not specified.

Summary

• 

Returns a table which is the result of reversing the table t while combining keys mapping to the same value with combiner function f.

Description

• 

The tablereverse function takes a table t and returns a table s which is a reversal of t, in the sense that the indices of s are the entries of t and the entries of s are a collection of the indices of t.

• 

By default, each index u appearing in the output table s is mapped to an entry s[u] which is a set of lists. Each list v in the set s[u] will satisfy the property that t[op(v)]=u.

• 

The optional argument c allows the specification of a combiner function c which accepts an expression sequence of inputs representing keys in t which map to the same value and returns some customized value.

• 

The default combiner function is simply the set constructor `{}` which collects all its arguments together in a set.

Examples

Ttableapple=fruit,orange=fruit,zucchini=vegetable,milk=dairy

Ttableapple=fruit,orange=fruit,zucchini=vegetable,milk=dairy

(1)

tablereverseT,nolist

tablefruit=apple,orange,dairy=milk,vegetable=zucchini

(2)

Instead of the default combiner function, use a list constructor and sort the resulting entries.

tablereverseT,`[]`,nolist,sort

tablefruit=apple,orange,dairy=milk,vegetable=zucchini

(3)

This table shows what ABO blood type a person has given their genetic profile.

BloodPhenotypestablesymmetric,`$`A,2=A,`$`B,2=B,`$`O,2=O,A,B=AB,A,O=A,B,O=B

BloodPhenotypestablesymmetric,A,A=A,B,O=B,A,B=AB,B,B=B,A,O=A,O,O=O

(4)

BloodGenotypestablereverseBloodPhenotypes

BloodGenotypestableO=O,O,AB=A,B,B,A,B=B,B,B,O,O,B,A=A,A,A,O,O,A

(5)

We can see by this result that there are multiple genetic combinations that result in type A, but only one which results in type O.

BloodGenotypesA

A,A,A,O,O,A

(6)

BloodGenotypesO

O,O

(7)

Compatibility

• 

The tablereverse command was introduced in Maple 2019.

• 

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

See Also

entries

indices

table

tablemerge