I want to bundle some actions of a task in a module to call it a few times. The task shall display some Graphics and it shall return some data (as a list).
But I can't do that (it would have been possible in Mma 4, where a Semicolon after Show did not suppress the display as in later versions, especially in the current one).
Consider
Task:=
Module[{}
,co=Table[{x,Cos[x]},{x,0,2*Pi,2*Pi/10}];
si=Table[{x,Sin[x]},{x,0,2*Pi,2*Pi/10}];
Show[{ListPlot[co,PlotStyle->Red]
,ListPlot[si,PlotStyle->Green]
,Plot[Cos[x], {x,0,2*Pi}, PlotStyle->Red]
,Plot[Sin[x], {x,0,2*Pi}, PlotStyle->Green]
}
] (* HERE! no Output, if there is a ; after the bracket *)
{1,2,co}
]; (* Task *)
If I call Task, I get:
This is a rather strange result! Why are there multiple copies of Show's output interleaved with the list of the line below (the data, I want to return from my Task)? I just expect one image and one list?
If I add a semicolon after the cosing bracket in the line marked "HERE!", I get
which is what I expect, but not what I am after. I want to produce 1st) a graphics (composed of several ones) on the screen, 2nd) a list of results computed in the module.
I know how to produce such an oputput, but to do so I would have to "unbundle" my module.
What is the silver bullet to create both a graphics on display and a result from a Module? (possibly one with parameters unlike my very much simpliefied example).
Print
your plots, add a semicolon after thePrint
command, and do the other stuff $\endgroup$