Writing functions in the order of how we say it

In computer science class, I always feel that defining constants before defining a function a bit backward in a math jargon where in textbook we usually write the equation and then say what the constants are so y[x]= a x for a =3. Something like that. With Mathematica and it’s symbolic evaluation control, you can write it in that order!

Here’s an example with list plot.

p=Inactive@ListPlot[data, option1] /. {data->{1,2,3},option1->{PlotLabel->"Title"}}
Activate[p]

And you get

1 Like

Hi Jack,

Another option is to use SetDelayed

ClearAll@p

p := ListPlot[data, option1]
data = {1, 2, 3}; option1 = {PlotLabel -> "Title"};

p
(* Same plot as the one you posted *)

option1 = {PlotLabel -> "Title", Frame -> True};
p
(* Plotted with a frame *)
2 Likes

Nice! Thanks!