tablemerge - Maple Help

Online Help

All Products    Maple    MapleSim


tablemerge

merge tables

 

Calling Sequence

Parameters

Options

Summary

Description

Details

Examples

Compatibility

Calling Sequence

tablemerge(t1, t2, options)

tablemerge(t1, t2, f, b1, ..., bn, options)

Parameters

t1, t2

-

tables

f

-

optional combiner function

b1, ..., bn

-

(optional) extra arguments

options

-

(optional) optional argument inplace

Options

• 

inplace = truefalse

  

Indicates that t1 should be modified in memory instead of allocating a new table.

Summary

• 

Returns a table which is the result of merging tables t1 and t2 subject to optional combiner f.

Description

• 

The tablemerge function returns a table t whose keys are all of the keys occurring in either of t1 or t2. The entries in the merged table corresponding to these keys are determined as follows:

– 

When a key k appears in exactly one of t1 or t2, the entry is unchanged from its original value in t1 or t2.

– 

When a key appears in both t1 and t2 and a combiner f was not provided, the entry from t2 is used.

– 

When a key k appears in both t1 and t2 and a combiner f was provided, the entry for k is f(t1[k],t2[k]).

• 

Additional arguments b1, ..., bn are passed to f.

Details

• 

The indexing function for the table returned by tablemerge is identical to the indexing function for t1. Any indexing function used in t2 will be ignored in the merge.

Examples

Merge a table with entries for "lunch" and "dessert", overriding the latter.

tablemergetablelunch=sandwich,dessert=apple,tabledessert=orange

tabledessert=orange,lunch=sandwich

(1)

Merge using union as the merge operation.

tablemergetable1=2,3,5,2=6,10,15,table1=7,11,13,`union`

table1=2,3,5,7,11,13,2=6,10,15

(2)

Merge using concatenation as the merge operation.

tablemergetableMessage=Hello ,tableMessage=World!,cat

tableMessage=Hello World!

(3)

Merge using concatenation, but using a custom delimiter as a 4th argument.

cat_delim := proc(x,y,delim) cat(x, delim, y) end proc:

tablemergetablepet=dog,vehicle=bike,tablepet=cat,vehicle=car,cat_delim,,

tablepet=dog,cat,vehicle=bike,car

(4)

Merge a table with symmetric indexing with one with ordinary indexing.

Atablesymmetric,1,2=A

Atablesymmetric,1,2=A

(5)

Btable1,2,3=B

Btable1,2,3=B

(6)

CtablemergeA,B

Ctablesymmetric,1,2,3=B,1,2=A

(7)

C3,1,2

B

(8)

Compatibility

• 

The tablemerge command was introduced in Maple 2015.

• 

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

• 

The tablemerge command was updated in Maple 2018.

See Also

indices

table