Coding Style. Using Operator vs Function Call
Operators and Syntactic Shortcuts vs Function Call
- Computer Science.
- Programing Language Syntax Design and Coding Style.
- Wolfram language coding style.
- i used to love the syntactic shortcuts
- e.g.
( #1+#2 &)
forFunction[{x,y}, x+y]
f /@ x
forMap[f,x]
f @@ x
forApply[f,x]
but now i prefer full function names. even sometimes prefer
SameQ[x,y]
insteadx === y
And[x,y]
insteadx && y
Because,
- Full names makes the code understandable to non-experts of the language.
- Also, completion makes it easier to type.
- Also, with brackets, it makes editing the code easier via syntactic units. E.g. You can select or delete a semantic unit via syntax.
(* lots operators *) Graphics3D[ Replace[Map[(Tube /@ Subsets[Tuples@Transpose@{#, # + 1}, {2}] &), CoordinateBoundsArray@Table[{0, 3}, 3], {-2}], v_List :> ((With[{xx = # . #}, If[xx < 0.00001, #, #/xx]]) &)@ v, {-2}], ViewVector -> {-.5, -.2, -1}]
(* less operators, more function call syntax *) Graphics3D[ Replace[Map[ Function[x, Map[ Tube, Subsets[Tuples[Transpose[{x, x + 1}]], {2}]] ] , CoordinateBoundsArray[Table[{0, 3}, 3]], {-2}], v_List :> Function[x, (With[{y = x . x}, If[y < 0.00001, x, x/y]]) ] [v], {-2}], ViewVector -> {-.5, -.2, -1}]