"Identity" (Incremental Object)
IncrementalObject["Identity"] [{e1,e2,…}]
creates an object that incrementally returns the values e1, e2, ….
IncrementalObject["Identity"][inc]
creates an object that incrementally returns the values from the incremental object or incremental function inc.
Details
- An "Identity" incremental object is useful as a source of values that come from the elements of an expression.
- The expression used as a source can be an object with any head, not necessarily List.
- The expression inc can be an expression with head IncrementalObject.
- The expression inc can be an object created by compiled code that uses IncrementalFunction.
- The following functions are also supported:
-
dsi===dsj True, if dsi equals dsj FullForm[ds] full form of ds InputForm[ds] input form of ds
Examples
open all close allBasic Examples (1)
Scope (4)
The expression argument does not have to be a list, just any compound expression:
obj = IncrementalObject["Identity"][f[a[1], b[1]]];
NextValue[obj]An incremental object can be used in Table:
obj = IncrementalObject["Identity"][{a, b}];
Table[e, {e, obj}]An incremental object can be used in Do:
obj = IncrementalObject["Identity"][{a, b}];
Do[Echo[e], {e, obj}]"Identity" incremental objects can use an IncrementalFunction as a source:
inc = FunctionCompile[IncrementalFunction[Function[{}, Do[IncrementalYield[i], {i, Infinity}]]]][];NextValue[inc]Create an incremental object using this as a source:
obj = IncrementalObject["Identity"][inc]NextValue[obj]This underlying IncrementalFunction uses a limit of Infinity so the Table will not return:
TimeConstrained[Table[e, {e, obj}], 1]"Identity" incremental objects can use an IncrementalObject as a source:
obj1 = IncrementalObject["Range"][3];
obj = IncrementalObject["Identity"][obj1]Table[e, {e, obj}]In practice it is not very useful to use an "Identity" incremental object in this way.
Properties & Relations (2)
InputForm (1)
InputForm returns the serialized contents of a "Identity" incremental object:
InputForm[IncrementalObject["Identity"][{1, 2, 3}]]This serialized form can be used to recreate the incremental object:
IncrementalObject["Identity", {"Source" :> {1, 2, 3}, "Position" :> 1}]SameQ (1)
SameQ can be used to test whether two incremental objects contain the same sequence at the same position:
obj1 = IncrementalObject["Identity"][{a, b, c, d}];
obj2 = IncrementalObject["Identity"][{a, b, c, d}];
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)