Timeline for Custom iterable objects
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 16, 2023 at 20:16 | answer | added | lericr | timeline score: 2 | |
Mar 19, 2016 at 2:36 | history | tweeted | twitter.com/StackMma/status/711018365842755585 | ||
Mar 18, 2016 at 11:30 | comment | added | The Vee |
Or, since Map would return the whole list anyway, you would be just as well of defining another set of upvalues that would first cache all the contents and then pass it on as a list. It would be natural to extend Normal for this purpose.
|
|
Mar 18, 2016 at 11:28 | comment | added | The Vee |
Well, Mathematica's only universal "interface" is a tree of objects. Map operates on this tree, and so do down/up/own/...value replacements. But the latter is an operation independent from the former. Map walks the actual structure (replacing (Map, f, (X, y, z)) by (X, (f, y), (f, z))), it does not ask for parts one-by-one. In fact, your object would not have parts, it just mimics being like that by transforming (Part, (DiskList, n)) (and presumably (Length, DiskList)) to something. But as pointed out above, you can write your own version of Map that would be based on For or Table .
|
|
Mar 18, 2016 at 11:21 | comment | added | Lorenzo Pistone |
@TheVee I'm not assuming that, it's the point of the question. What does Map expect from and object? Does it use Length , or does it use some compiled magic that I'll never be able to fool with an upvalue? and is there a way to "enumerate" these requirements rather than going by trial and error?
|
|
Mar 18, 2016 at 11:18 | comment | added | The Vee |
Why would you assume that Map uses iterators, in the first place? Help says it operates on the tree model of expressions, and makes a plenty of references to relevant concepts like levelspec and depth. So unless your "custom object" is a tree (and therefore nothing new to MMA), I would say Map is not the command for you.
|
|
Mar 18, 2016 at 11:04 | history | asked | Lorenzo Pistone | CC BY-SA 3.0 |