I love the shorthand /@. It is amazing for readability (and laziness when typing). However, right now I find that I need Map at level 2, i.e. Map[f, List[List[a,b],List[c,d]], {2}], a lot and I'd wish there was a similar shorthand notation available for a map at level 2. Is there? If not, can we make one?
|
|
||||
|
I'm not aware of a simple one, but perhaps you could make your own? The following is not great because it requires you to enter
Then: |
|||
|
|
|
Rojo shows a way in Is it possible to define custom compound assignment operators like ⊕= similar to built-ins +=, *= etc?
Now: To enter this select I actually used this (or code very like it) for a while but I got tired of having to translate to the long form for posting here so I stopped. You could use a variation of you want to allow for full levelspec rather map at (only) level n. PerformanceSyntactically I like Kuba's suggestion of An aside: the only reason I am offering this critique is because I find this form desirable; I had the same reaction as march, just longer ago: "That's the usefulness of operator forms that I've been waiting for." I still hope that at least the performance aspect will be improved in future versions. Unfortunately in the current implementation (or at least 10.1.0, but I don't think this has changed in v11) Operator Forms cannot themselves be compiled, therefore
At risk of belaboring a point there is another limitation or at least difference regarding Compare:
Clearly these operations are not equivalent. |
||||
|
|



Map[f] /@ {{1, 2}}? you can always define new functionmap2[f,l]. – Kuba 12 hours agoMapand/@. – Kuba 10 hours ago