Modulinos: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 1,475: Line 1,475:
$ ./test
$ ./test
Test: The meaning of life is 42</lang>
Test: The meaning of life is 42</lang>
=={{header|SAC}}==
Makefile:
<lang make>all: scriptedmain


scriptedmain: ScriptedMain.sac
sac2c -o scriptedmain ScriptedMain.sac -Dscriptedmain


test: test.sac ScriptedMain.sac
sac2c ScriptedMain.sac
sac2c -o test test.sac

clean:
-rm test
-rm test.c
-rm libScriptedMainTree.so
-rm libScriptedMainMod.so
-rm libScriptedMainMod.a
-rm scriptedmain
-rm scriptedmain.c</lang>

ScriptedMain.sac:
<lang c>#ifndef scriptedmain
module ScriptedMain;
#endif

use StdIO: all;
use Array: all;
export all;

int meaning_of_life() {
return(42);
}

#ifdef scriptedmain
int main() {
printf("Main: The meaning of life is %d\n", meaning_of_life());
return(0);
}
#endif</lang>

test.sac:
<lang c>use StdIO: all;
use Array: all;
use ScriptedMain: all;

int main() {
printf("Test: The meaning of life is %d\n", meaning_of_life());
return(0);
}</lang>

Example:
<lang sh>$ make
$ make test
$ ./scriptedmain
Main: The meaning of life is 42
$ ./test
Test: The meaning of life is 42</lang>
=={{header|Scala}}==
=={{header|Scala}}==
[[Category:Scala Implementations]]
[[Category:Scala Implementations]]
{{libheader|Scala}}
{{libheader|Scala}}
===Unix version===
===Unix shell script===
This code must be stored as a shell script.
<lang bash>#!/bin/sh
<lang bash>#!/bin/sh
exec scala "$0" "$@"
exec scala "$0" "$@"
Line 1,492: Line 1,548:
println(collatz.toList)
println(collatz.toList)
println(s"It has ${collatz.length} elements.")</lang>
println(s"It has ${collatz.length} elements.")</lang>
===Windows cmd.exe interpretation===
===Windows Command Scrip===
This code must be stored as a Windows Command Script e.g. Hailstone.cmd
<lang winbatch>::#!
<lang winbatch>::#!
@echo off
@echo off
Line 1,565: Line 1,622:
Transcript show: 'Test: The meaning of life is ', ((ScriptedMain meaningOfLife) printString); cr.</lang>
Transcript show: 'Test: The meaning of life is ', ((ScriptedMain meaningOfLife) printString); cr.</lang>


=={{header|SAC}}==

Makefile:
<lang make>all: scriptedmain

scriptedmain: ScriptedMain.sac
sac2c -o scriptedmain ScriptedMain.sac -Dscriptedmain

test: test.sac ScriptedMain.sac
sac2c ScriptedMain.sac
sac2c -o test test.sac

clean:
-rm test
-rm test.c
-rm libScriptedMainTree.so
-rm libScriptedMainMod.so
-rm libScriptedMainMod.a
-rm scriptedmain
-rm scriptedmain.c</lang>

ScriptedMain.sac:
<lang c>#ifndef scriptedmain
module ScriptedMain;
#endif

use StdIO: all;
use Array: all;
export all;

int meaning_of_life() {
return(42);
}

#ifdef scriptedmain
int main() {
printf("Main: The meaning of life is %d\n", meaning_of_life());
return(0);
}
#endif</lang>

test.sac:
<lang c>use StdIO: all;
use Array: all;
use ScriptedMain: all;

int main() {
printf("Test: The meaning of life is %d\n", meaning_of_life());
return(0);
}</lang>

Example:
<lang sh>$ make
$ make test
$ ./scriptedmain
Main: The meaning of life is 42
$ ./test
Test: The meaning of life is 42</lang>


=={{header|Tcl}}==
=={{header|Tcl}}==