Modulinos: Difference between revisions

m
(Created Nim solution.)
m (→‎{{header|Wren}}: Minor tidy)
 
(6 intermediate revisions by one other user not shown)
Line 423:
(load "scriptedmain.el" nil t)
(message "Test: The meaning of life is %d" (meaning-of-life)))</syntaxhighlight>
 
=={{header|EMal}}==
{{trans|Wren}}
<syntaxhighlight lang="emal">
^|We have created a module named ModulinosPart.emal.
|^
in Org:RosettaCode
type ModulinosPart
fun meaningOfLife = int by block do return 42 end
fun main = void by block do writeLine("The meaning of life is " + meaningOfLife() + ".") end
if Runtime.direct() do main() end
</syntaxhighlight>
{{out}}
<pre>
emal.exe Org\RosettaCode\ModulinosPart.emal
The meaning of life is 42.
</pre>
<syntaxhighlight lang="emal">
^|Then we create a new module named Modulinos.emal,
|this imports the previous module.
|^
in Org:RosettaCode
load :ModulinosPart
type Modulinos
fun main = int by List args
writeLine("Who says the meaning of life is " + ModulinosPart.meaningOfLife() + "?")
return 0
end
exit main(Runtime.args)
</syntaxhighlight>
{{out}}
<pre>
emal.exe Org\RosettaCode\Modulinos.emal
Who says the meaning of life is 42?
</pre>
 
=={{header|Erlang}}==
Line 1,984 ⟶ 2,019:
 
First we create a module for our modulino:
<syntaxhighlight lang="ecmascriptwren">/* modulinoModulinos.wren */
 
var MeaningOfLife = Fn.new { 42 }
Line 1,994 ⟶ 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,005 ⟶ 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