A+B: Difference between revisions
Content added Content deleted
Childishbeat (talk | contribs) m (Wee Basic has been added.) |
(Add Genie) |
||
Line 1,868: | Line 1,868: | ||
=={{header|Gema}}== |
=={{header|Gema}}== |
||
<lang gema><D> <D>=@add{$1;$2}</lang> |
<lang gema><D> <D>=@add{$1;$2}</lang> |
||
=={{header|Genie}}== |
|||
<lang genie>[indent=4] |
|||
/* |
|||
A+B in Genie |
|||
valac aplusb-genie.gs |
|||
./aplusb-genie |
|||
*/ |
|||
init |
|||
a:int64 = 0 |
|||
b:int64 = 0 |
|||
leftover:string = "" |
|||
print "Enter A and B, two numbers separated by space" |
|||
line:string = stdin.read_line() |
|||
res:bool = int64.try_parse(line, out a, out leftover) |
|||
res = int64.try_parse(leftover, out b) |
|||
warning:string = " outside range (-1000, 1000), but it's ok, no one will tell" |
|||
if a < -1000 or a > 1000 |
|||
print "A" + warning |
|||
if b < -1000 or b > 1000 |
|||
print "B" + warning |
|||
print "From %s\nA + B = %llu", line, a+b</lang> |
|||
{{out}} |
|||
<pre>prompt$ valac aplusb-gs.gs |
|||
prompt$ ./aplusb-gs |
|||
Enter A and B, two numbers separated by space |
|||
20 22 |
|||
From 20 22 |
|||
A + B = 42 |
|||
prompt$ echo '123 234' | ./aplusb-gs |
|||
Enter A and B, two numbers separated by space |
|||
From 123 234 |
|||
A + B = 357 |
|||
prompt$ echo '123 2345' | ./aplusb-gs |
|||
Enter A and B, two numbers separated by space |
|||
B outside range (-1000, 1000), but it's ok, no one will tell |
|||
From 123 2345 |
|||
A + B = 2468</pre> |
|||
=={{header|GML}}== |
=={{header|GML}}== |