Maintain a list of things
How to hold onto and modify a list
Sometimes you may want not only to create a list, but also to hold onto it and make changes to it over time. One way to do that is with a feedback loop, as in the example composition below (
). It maintains a list of colors, randomly changing one of them every 1 second.
Another way you might want to maintain a list is to accumulate a queue of items over time, using the Enqueue node. A queue in this node is like a queue of people waiting in line. It’s first-in-first-out, meaning that new items get added to the end of the line, and the item that’s been waiting in line the longest is the next one that can leave the queue. Here’s an example that uses Enqueue to remember the positions of the 5 most recent mouse presses.