A+B: Difference between revisions

816 bytes added ,  1 year ago
no edit summary
(A+B in Minimal BASIC)
No edit summary
Line 2,587:
(b (cadr numbers)))
(message "%d" (+ a b)))</syntaxhighlight>
 
=={{header|EMal}}==
<syntaxhighlight lang="emal">
fun main = int by List args
text input = when(args.length == 1, args[0], ask(text, "Enter n integers separated by a space: "))
int sum, count
for each text word in input.split(" ")
word = word.trim()
if word.isEmpty() do continue end # ignore empty words
int nr = int!word # this can raise an exception
if abs(nr) > 1000
Event.error(0, "Integers must be in the interval [-1000, 1000]").raise()
end
sum += nr
++count
end
if count < 2 do Event.error(1, "At least two integers must be provided").raise() end
writeLine("The sum of " + count + " integers is: " + sum)
return 0
end
exit main(Runtime.args)
</syntaxhighlight>
{{out}}
<pre>
emal.exe Org\RosettaCode\Aplusb.emal " 9 8 "
The sum of 2 integers is: 17
</pre>
 
=={{header|Emojicode}}==
214

edits