A function needs to cope with many different forms of input, such as different heads (Plus
, Times
, Power
, etc). Should the function be defined with multiple Mathematica delayed assignments (such as “PostScriptForm[Times[-1, thing_]] := …
”) or with one large assignment, likely to be of the form PostScriptForm[thing_] := Which[ MatchQ[…], …, MatchQ[…], …, ]
?
If the context helps, it is about PostScriptForm
, which converts to PostScript as CForm
converts to C.
Either form could work: which is more natural idiomatic Mathematica?
Edit: a related question. If multiple statements, as recommended in @eldo’s answer, should the statements be in different cells, or in the same cell separated by a blank line, or in the same cell without separations? Again, which is more natural idiomatic Mathematica?