Modulinos: Difference between revisions

m
m (→‎{{header|Wren}}: Minor tidy)
 
(4 intermediate revisions by one other user not shown)
Line 427:
{{trans|Wren}}
<syntaxhighlight lang="emal">
^|weWe have created a module named ModulinoModulinosPart.emal.
|^
in Org:RosettaCode
type ModulinoModulinosPart
fun meaningOfLife = int by block do return 42 end
fun main = void by block do writeLine("The meaning of life is " + meaningOfLife() + ".") end
Line 437:
{{out}}
<pre>
emal.exe Org\RosettaCode\ModulinoModulinosPart.emal
The meaning of life is 42.
</pre>
<syntaxhighlight lang="emal">
^|thenThen we create a new module named ModulinoMainModulinos.emal,
| this importimports the previous module.
|^
in Org:RosettaCode
load :ModulinoModulinosPart
type ModulinoMainModulinos
fun main = int by List args
writeLine("Who says the meaning of life is " + ModulinoModulinosPart.meaningOfLife() + "?")
return 0
end
Line 455:
{{out}}
<pre>
emal.exe Org\RosettaCode\ModulinoMainModulinos.emal
Who says the meaning of life is 42?
</pre>
Line 2,019:
 
First we create a module for our modulino:
<syntaxhighlight lang="ecmascriptwren">/* modulinoModulinos.wren */
 
var MeaningOfLife = Fn.new { 42 }
Line 2,029:
// Check if it's being used as a library or not.
import "os" for Process
if (Process.allArguments[1] == "modulinoModulinos.wren") { // if true, not a library
main.call()
}</syntaxhighlight>
Line 2,040:
 
Next we create another module which imports the modulino:
<syntaxhighlight lang="ecmascriptwren">/* modulino_mainModulinos_main.wren */
 
import "./modulinoModulinos" for MeaningOfLife
 
var main = Fn.new {
9,476

edits