Modulinos: Difference between revisions

Added Mathematica
(Added SAC)
(Added Mathematica)
Line 743:
sm = require("scriptedmain")
print("Test: The meaning of life is " .. sm.meaningoflife())</lang>
 
=={{header|Mathematica}}==
 
scriptedmain.ma
<lang mathematica>#!/usr/bin/env MathKernel -script
 
MeaningOfLife[] = 42
 
ScriptName[] = Piecewise[
{
{"Interpreted", Position[$CommandLine, "-script", 1] == {}}
},
$CommandLine[[Position[$CommandLine, "-script", 1][[1,1]] + 1]]
]
 
Program = ScriptName[];
 
If[StringMatchQ[Program, ".*scriptedmain.*"],
Print["Main: The meaning of life is " <> ToString[MeaningOfLife[]]]
]</lang>
 
test.ma:
<lang mathematica>#!/usr/bin/env MathKernel -script
 
Get["scriptedmain.ma"]
 
Print["Test: The meaning of life is " <> ToString[MeaningOfLife[]]]</lang>
 
Example:
<lang sh>$ ./scriptedmain.ma
Main: The meaning of life is 42
wonko:scriptedmain andrew$ ./test.ma
Test: The meaning of life is 42</lang>
 
In Mac and Windows, the output will be surrounded by spurious quotes.
 
=={{header|newLISP}}==
Anonymous user