Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
A data structure meant for accumulating items efficiently
ResourceFunction["ExpressionBag"]["id"] retrieves the expression bag specified by "id". | |
ResourceFunction["ExpressionBag"][list] creates an expression bag using list as the initial data. | |
ResourceFunction["ExpressionBag"][…][prop] returns the specified property of the bag. | |
ResourceFunction["ExpressionBag"][…]["Add",expr] adds expr to the bag. | |
ResourceFunction["ExpressionBag"][…]["Part",part] gets the expression specified by part from the bag. |
Length[bag] | the number of items contained in the bag |
Append[bag,expr] | adds expr to the bag |
bag[[part]] | gets items from the bag specified by Part specification part |
Get[bag] | gets all items from the bag |
Information[bag] | returns a summary of information about the bag |
DeleteObject[bag] | permanently delete bag |
Create an empty expression bag:
In[1]:= | ![]() |
Out[1]= | ![]() |
Add values to the expression bag:
In[2]:= | ![]() |
Out[2]= | ![]() |
Add another value:
In[3]:= | ![]() |
Out[3]= | ![]() |
Retrieve all values from the bag:
In[4]:= | ![]() |
Out[4]= | ![]() |
Create an expression bag from some initial data:
In[5]:= | ![]() |
Out[5]= | ![]() |
Retrieve parts of the expression bag:
In[6]:= | ![]() |
Out[6]= | ![]() |
In[7]:= | ![]() |
Out[7]= | ![]() |
Create a named expression bag:
In[8]:= | ![]() |
Out[8]= | ![]() |
Reference the bag by name:
In[9]:= | ![]() |
Out[9]= | ![]() |
Get information about an expression bag:
In[10]:= | ![]() |
Out[10]= | ![]() |
In[11]:= | ![]() |
Out[11]= | ![]() |
Delete an expression bag:
In[12]:= | ![]() |
Out[12]= | ![]() |
In[13]:= | ![]() |
The expression bag can no longer be referenced by name:
In[14]:= | ![]() |
Out[14]= | ![]() |
Get all expression bags in the current session:
In[15]:= | ![]() |
Out[15]= | ![]() |
Delete them:
In[16]:= | ![]() |
Out[16]= | ![]() |
Keep a running history of inputs in the current session:
In[17]:= | ![]() |
Out[17]= | ![]() |
In[18]:= | ![]() |
Out[18]= | ![]() |
Evaluate some inputs:
In[19]:= | ![]() |
Out[19]= | ![]() |
In[20]:= | ![]() |
Out[20]= | ![]() |
In[21]:= | ![]() |
Out[21]= | ![]() |
Get the list of inputs entered so far:
In[22]:= | ![]() |
Out[22]= | ![]() |
Create a notebook showing input history:
In[23]:= | ![]() |
Out[23]= | ![]() |
Restore $PreRead to its default:
In[24]:= | ![]() |
An expression bag can be used as a collection that allows efficient insertion of items:
In[25]:= | ![]() |
Out[25]= | ![]() |
In[26]:= | ![]() |
Out[26]= | ![]() |
Compare to using AppendTo and a List:
In[27]:= | ![]() |
Out[28]= | ![]() |
The results are equivalent:
In[29]:= | ![]() |
Out[29]= | ![]() |
The insertion time for an expression bag is not affected by the item count:
In[30]:= | ![]() |
Out[30]= | ![]() |
In[31]:= | ![]() |
Out[31]= | ![]() |
Compare to using AppendTo and List:
In[32]:= | ![]() |
Out[20]= | ![]() |
In[33]:= | ![]() |
Out[33]= | ![]() |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License