Timeline for answer to V10's Operator Forms - what are they good for? by Simon Woods
Current License: CC BY-SA 3.0
Post Revisions
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 10, 2024 at 0:44 | comment | added | Tapiocaweasel |
@RonaldMonson is it still possible to use the Notation package to redefine @/ as you mentioned? I would lover to do this. I know I can do //Map[f] but... I don't want to. I was under the impression that it was simply impossible to redefine something like @/. Help me Ronald Monson! You're my only hope!
|
|
| Aug 7, 2014 at 18:13 | comment | added | Rojo |
The ~(#2 /@ #1 &)~ form is nicer than the //Max/@#& in that you keep the ability to continue with other infixes like ~Position~2 without having precedence problems. +1
|
|
| Aug 7, 2014 at 18:13 | comment | added | Taliesin Beynon | Excellent example! | |
| Aug 4, 2014 at 13:01 | comment | added | Ronald Monson |
I agree that a // Position[0] // SortBy[Last] // Map[Max] seems (the most) natural. Perhaps even more so than Map[Max] @* SortBy[Last] @* Position[0] @* a due to the spacing and a natural proclivity to read left-to-right. I suspect that increased postfix usage maybe end up being one of the main effects of operator forms on code bases.
|
|
| Aug 4, 2014 at 12:02 | comment | added | Ronald Monson |
Yes I found I was always using the syntax expr // f /@ # & to the point where I actually went to the trouble of using the Notation package to redefine @/ as being the postfix shortform of Map i.e. making expr @/ f equivalent to f /@ expr. It seemed natural to imagine it being applied backwards as in the mirror image of the prefix shortform.
|
|
| Aug 4, 2014 at 11:53 | comment | added | Ronald Monson | "... This is only possible when using functions which take the data as their first argument." Not all operator forms take the data as the first argument e.g. MapAt has the data as the second argument but yes in the functions used above the "pure form" is necessary. Actually, this was my point in my answer about potentially automating the process where the curried form could guess the missing argument and maintain this flexibility or individual coding style. It is a big ask though. | |
| Aug 4, 2014 at 11:47 | comment | added | Ronald Monson | Interesting use of infix notation although for my thought processes it doesn't (at least now) seem to improve readability. If I had to venture a reason it would be that the focus seems to be more on the operator and less on the structure that is being progressively transformed. I have to unpack the transformation by first scanning left and right. | |
| Aug 4, 2014 at 10:03 | history | edited | Simon Woods | CC BY-SA 3.0 |
deleted 34 characters in body
|
| Aug 4, 2014 at 10:02 | comment | added | Simon Woods |
@Mr.Wizard, I'm not sure either. I've noticed that some folk avoid @ and // too, so maybe using a single consistent style for function application is a more important consideration for them than other aspects of readability.
|
|
| Aug 4, 2014 at 8:40 | comment | added | Simon Woods |
@xzczd, yes you could use // the way I have written it. Perhaps that would be clearer actually.
|
|
| Aug 4, 2014 at 4:40 | comment | added | xzczd♦ |
Er… is the /* in the last example irreplaceable? // seems to have the same effect.
|
|
| Aug 4, 2014 at 4:12 | comment | added | Rojo | @Mr.Wizard Infix rules | |
| Aug 4, 2014 at 0:04 | comment | added | Mr.Wizard | Then again this answer has accumulated six votes at present, the last one mine, so perhaps I/we have manged to convince more people? I almost included this infix angle in my own answer then thought: "Nah, I'll get hoisted on a pike for it (again); better not." | |
| Aug 4, 2014 at 0:03 | comment | added | Mr.Wizard | Although I think you know I fully agree with you regarding "I am fond of infix notation ... more readable than the 'conventional'" it seems most people disagree. I'm really not sure why. Simple unfamiliarity? | |
| Aug 3, 2014 at 21:37 | comment | added | eldo | +1 This is the first answer to this question I understand by just reading it :) | |
| Aug 3, 2014 at 21:32 | history | answered | Simon Woods | CC BY-SA 3.0 |