I'm trying to improve my code's performance by using reap and sow instead of appendto and it works, but I hit a small obstacle. Since my code is building two lists simultaneously, I need to use sow with tag and afterwards I take the two resulting things from it. But I don't know which is which! I used tag to construct the lists so it seems natural to expect I would be able to call the parts of the output with that tag, like outputlist[[ tag used ]] or something similar. But I couldn't find anything like it.
The best solution I can think of is to just add a token element to each tag and I know that the list with a first element "this is from tag 1" is the tag 1 list. But if there's a more elegant way of doing that it would be nice.
Reap[<code>, {"tag1", "tag2"}]
? $\endgroup$Reap
into anAssociation
. Then you can access the tags as desired. $\endgroup$Reap
under "Scope", "Generalizations & Extensions" and "Properties & Relations" -- there's one relevant example in each section $\endgroup$