bag Reference

Store a collection of numbers.

bag

Examples

Inlets

in1 [bang, list, number]

bang : A bang in the left inlet causes bag to output the stored contents as a series of individual values in first-in-last-out (FILO) order.

number : When a single number is received, it will either be added or removed based on the state of the right inlet. If the right inlet is set to any non-zero value, it will be added, and if it is set to zero, the item will be removed.

list : When a list is received, the first element will be added if the second is non-zero or removed if it is zero.

If the duplicate attribute is enabled (set to 1), removing a value will remove only the most recently added instance of a number.

Sets whether items are added (non-zero) or removed (zero). This only affects incoming messages with a single number. Values that arrive as a list are added or removed based on whether the value of the second element is non-zero or zero.

Outlets

out [number]

Output all items when bang is received

sizeOut [number]

Size of bag

Dynamic Attributes

These attributes can be modified in the code during execution using the set object

clear [bang]

Clears all contents of the bag object and immediately sets the item count to 0.

duplicate [number] (default: 0)

When enabled, duplicates of the same value can be stored. Changing the state of this attribute always clears the stored contents and immediately sets the item count to 0.

in1 [bang, list, number]

bang : A bang in the left inlet causes bag to output the stored contents as a series of individual values in first-in-last-out (FILO) order.

number : When a single number is received, it will either be added or removed based on the state of the right inlet. If the right inlet is set to any non-zero value, it will be added, and if it is set to zero, the item will be removed.

list : When a list is received, the first element will be added if the second is non-zero or removed if it is zero.

If the duplicate attribute is enabled (set to 1), removing a value will remove only the most recently added instance of a number.

Sets whether items are added (non-zero) or removed (zero). This only affects incoming messages with a single number. Values that arrive as a list are added or removed based on whether the value of the second element is non-zero or zero.

See Also

Name Description
bag Store a collection of numbers
funbuff Store pairs of numbers
offer Store one-time number pairs
list.reg Store a list, bang it out.
list.rev Reverse a list