678 reputation
211
bio website
location Perth, Australia
age
visits member for 1 year, 11 months
seen Aug 12 at 4:10

1d
awarded  Popular Question
Aug
10
comment V10's Operator Forms - what are they good for?
@Mr.Wizard No problem, upvoted all answers but find ones with certain takeaways perhaps the most useful. Thanks, more examples are always welcome and I think needed in this area.
Aug
9
revised Changing Values in an Association using Map
fixed grammar
Aug
9
suggested suggested edit on Changing Values in an Association using Map
Aug
7
awarded  Good Question
Aug
7
accepted V10's Operator Forms - what are they good for?
Aug
7
comment V10's Operator Forms - what are they good for?
In a previous comment it was mentioned how operator forms can be used to refactor code as part of improving readability but also efficiency. As illustrated by other answers, operator forms can replace occurrences of Function (introduced to deal with nested #&'s) suggesting a refactoring in the code of this answer and in particular a dropping of one of the Table's iterators. The snippet Table[youngest[Select[#age == x &] /* CountsBy[#survived &] /* ({#[True], #[False]} &)]//Normal,{x,Range@cutoff}] is equivalent, perhaps of comparable readability but certainly improved efficiency-wise.
Aug
7
revised V10's Operator Forms - what are they good for?
added 1114 characters in body
Aug
7
revised V10's Operator Forms - what are they good for?
added 1430 characters in body
Aug
4
comment V10's Operator Forms - what are they good for?
This last point -defining your own operator form if needs be - is touched upon in the documentation (e.g. via the matches definition in the "titanic neat example") although perhaps it would have been worth emphasising a little more given its role in building up more powerful queries. It also relates to my speculation about these forms being automatically detectable given that most functions have a natural "data argument" (and/or other arguments can be inferred from the context). It also raises the spectre of wholesale code refactoring for improving the maintainability of legacy codebases.
Aug
4
comment V10's Operator Forms - what are they good for?
Two useful takeaways here: Firstly, the extra brevity from avoiding (#&) is only part of the story. Operator forms also remove the need for Function usage for nested pure functions but further, even this doesn't seem to capture the advantages since when it comes to readability and conceptualisation it really does seem to be a case of the "whole being greater than the sum of the parts". Secondly, even when an operator form is not built in, one can readily be defined if warranted by the code.
Aug
4
comment V10's Operator Forms - what are they good for?
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
comment V10's Operator Forms - what are they good for?
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
comment V10's Operator Forms - what are they good for?
"... 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
comment V10's Operator Forms - what are they good for?
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
revised V10's Operator Forms - what are they good for?
deleted 6 characters in body
Aug
4
awarded  Nice Question
Aug
3
revised V10's Operator Forms - what are they good for?
added 3 characters in body
Aug
3
revised V10's Operator Forms - what are they good for?
deleted 17 characters in body
Aug
3
comment V10's Operator Forms - what are they good for?
Corrected. Thanks.