"Tuples" (Incremental Object)
IncrementalObject["Tuples"] [list,n]
creates an object that incrementally returns values that are n-tuples of list.
IncrementalObject["Tuples"] [{list1,list2,…}]
creates an object that incrementally returns values that are tuples whose i th element is from listi.
Examples
open all close allBasic Examples (1)
Create a new "Tuples" incremental object:
obj = IncrementalObject["Tuples"][{a, b}, 2]NextValue[obj]NextValue[obj]NextValue[obj]NextValue[obj]There are no more values, and a failure object is returned:
NextValue[obj]Scope (3)
An incremental object can be used in Table:
obj = IncrementalObject["Tuples"][{a, b, c}, 2];
Table[e, {e, obj}]An incremental object can be used in Do:
obj = IncrementalObject["Tuples"][{a, b}, 2];
Do[Echo[e], {e, obj}]Permutations can be processed incrementally even if the total number of permutations is very long:
obj = IncrementalObject["Tuples"][Range[20], 4];
Do[NextValue[obj], 10000]NextValue[obj]Properties & Relations (3)
The values return by a "Tuples" incremental object are the same as those returned by Tuples.
obj = IncrementalObject["Tuples"][{a, b, c}, 2];
Table[e, {e, obj}]Tuples[{a, b, c}, 2]InputForm (1)
InputForm returns the serialized contents of a "Tuples" incremental object:
InputForm[IncrementalObject["Tuples"][{a, b, c}, 2]]This serialized form can be used to recreate the incremental object:
IncrementalObject["Tuples", {"Data" :> {0, 0, 0, 0}, "Exhausted" :> False, "Source" :> {{a, b, c}, {a, b, c}}}]SameQ (1)
SameQ can be used to test whether two incremental objects contain the same sequence at the same position:
obj1 = IncrementalObject["Tuples"][{a, b, c, d}, 2];
obj2 = IncrementalObject["Tuples"][{a, b, c, d}, 2];
obj1 === obj2If one objects moves to the next value, the two objects are no longer the same:
NextValue[obj1];
obj1 === obj2Advancing the other object means that they are both now the same:
NextValue[obj2];
obj1 === obj2See Also
Related Guides
History
Introduced in 2026 (15.0)