"Map" (Incremental Object)
IncrementalObject["Map"] [{e1,e2,…},f]
creates an object that incrementally returns values that apply f to the ei.
IncrementalObject["Map"] [inc,f]
creates an object that incrementally returns values from the incremental object or incremental function inc that apply f to the ei.
Details
- A "Map" incremental object is useful to modify 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["Map"][Length, f[a[1], a[1, 2]]];NextValue[obj]NextValue[obj]There are no more values, and a failure object is returned:
NextValue[obj]An incremental object can be used in Table:
obj = IncrementalObject["Map"][Abs, Range[-3, 3]];
Table[e, {e, obj}]An incremental object can be used in Do:
obj = IncrementalObject["Map"][Abs, Range[-1, 1]];
Do[Echo[e], {e, obj}]"Map" incremental objects can use an IncrementalObject as a source:
iobj = IncrementalObject["Range"][-3, 3];Create an incremental object using the incremental object as a source:
obj = IncrementalObject["Map"][Abs, iobj]A list of all the values from the incremental object:
Table[e, {e, obj}]"Map" incremental objects can use an IncrementalFunction as a source:
ifun = FunctionCompile[IncrementalFunction[Function[{}, Do[IncrementalYield[i], {i, Infinity}]]]][];NextValue[ifun]Create an incremental object using the incremental function as a source:
obj = IncrementalObject["Map"][N, ifun]NextValue[obj]This underlying IncrementalFunction uses a limit of Infinity so the Table will not return:
TimeConstrained[Table[e, {e, obj}], 1]Properties & Relations (2)
InputForm (1)
InputForm returns the serialized contents of a "Map" incremental object:
InputForm[IncrementalObject["Map"][f, {1, 2, 3}]]This serialized form can be used to recreate the incremental object:
IncrementalObject["Map", {"Function" :> f, "Source" :> 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["Map"][f, {a, b, c, d}];
obj2 = IncrementalObject["Map"][f, {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)