Skip to main content

Timeline for Mapping at arbitrary nested list

Current License: CC BY-SA 3.0

8 events
when toggle format what by license comment
Dec 20, 2015 at 22:05 comment added andre314 @Oleksandr R. @garej I don't know if in the OP mind f is intended to stay as a simple symbol or is intended to become a more complex expression, for exemple a function like x^2+x+1. In that case the solution poss=Level[MapIndexed[f,anl,{-1}],{-2}] doesn't work.
Dec 20, 2015 at 21:32 comment added Oleksandr R. @garej and the other half can be solved with Level as also discussed, and as I showed in my comment above. So, if you're happy with it, I'll vote. Please note that questions closed as duplicates will not be deleted: it's just a way to organise the site.
Dec 20, 2015 at 21:23 vote accept garej
Dec 20, 2015 at 21:19 comment added garej @OleksandrR., you are right, Map[f, anl, {-1}] solves a half of the problem and it is up to you to decide (I can edit the post to add the link). I'm glad to get several useful ways of doing this anyway.
Dec 20, 2015 at 21:04 history edited andre314 CC BY-SA 3.0
added 10 characters in body
Dec 20, 2015 at 21:00 comment added Oleksandr R. @garej yes, it does. You can use Map[f, anl, {-1}]. But in your question you wanted the positions of the leaves as well, and I think andre's solution is one of the most obvious ways to get this. Another could be poss = Level[MapIndexed[f, anl, {-1}], {-2}].
Dec 20, 2015 at 20:45 comment added garej yes, that is what I need. Thank you for Reap/Sow solution. Frankly, I thought that some simple function exists that map at all final leaves of the tree.
Dec 20, 2015 at 20:41 history answered andre314 CC BY-SA 3.0