MergingFunction

MergingFunction

is an option for functions such as PersistentValue that specifies a function to apply to the list of values found.

Details

  • Some common settings for MergingFunction include:
  • First
  • return only the first value
  • Identityreturn the list of all values
    Flattenreturn the flattened list of all values
    Merge[f]merge associations using the function f

Examples

open allclose all

Basic Examples  (2)

Create a number of persistent values with key "pval" at different persistence locations:

In[1]:=
Click for copyable input

Give all values that exist on $PersistencePath:

In[2]:=
Click for copyable input
Out[2]=

Give only the first value found:

In[3]:=
Click for copyable input
Out[3]=

Create a number of persistent values with key "lval" at different persistence locations:

In[1]:=
Click for copyable input

Give the list of all values found:

In[2]:=
Click for copyable input
Out[2]=

Join the list values:

In[3]:=
Click for copyable input
Out[3]=

Flatten all sublists:

In[4]:=
Click for copyable input
Out[4]=

Scope  (3)

See Also

PersistentValue  $PersistencePath  KeyCollisionFunction

Introduced in 2017
(11.1)