This repository was archived by the owner on Jun 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from thejoeejoee/develop
Release [1.4.6]
Showing
23 changed files
with
360 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
' maximum for C integer | ||
|
||
scope | ||
dim a as double = 1.79761e+308 | ||
print a; | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,10 @@ | |
{ | ||
"name": "41", | ||
"stdout": " 2147483647" | ||
}, | ||
{ | ||
"name": "42", | ||
"stdout": " 1.79769e+308" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
' Basic UNTIL loop | ||
|
||
scope | ||
dim i as integer | ||
|
||
do until i > 10 | ||
print i; | ||
i = i + 1 | ||
loop | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
' Simple do ... loop while | ||
|
||
scope | ||
dim i as integer | ||
|
||
do | ||
print i; | ||
i = i + 2 | ||
loop while i < 9 | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'Infinite loop with exit | ||
|
||
scope | ||
dim i as integer | ||
|
||
do | ||
i = i + 1 | ||
|
||
if i > 10 then | ||
exit do | ||
else | ||
i = i + 1 | ||
print i; | ||
end if | ||
loop | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'Continue in nested loops | ||
|
||
scope | ||
dim i as integer | ||
dim j as integer | ||
|
||
do while i < 10 | ||
j = 0 | ||
do until j > 8 | ||
j = j + 1 | ||
if i = 5 then | ||
Continue do | ||
else | ||
j = j + 1 | ||
end if | ||
print j; | ||
loop | ||
|
||
print !"\n"; | ||
i = i + 1 | ||
loop | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'Exit in nested loops | ||
|
||
scope | ||
dim i as integer | ||
dim j as integer | ||
|
||
do | ||
i = i + 1 | ||
j = 0 | ||
|
||
do until j > 100 | ||
j = j + 1 | ||
|
||
if j > 10 then | ||
exit do | ||
else | ||
i = i + 1 | ||
end if | ||
print j; | ||
loop | ||
|
||
print i; | ||
|
||
if i > 100 then | ||
exit do | ||
else | ||
i = i + 1 | ||
end if | ||
print !","; | ||
loop | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'Simple for cycle | ||
|
||
scope | ||
dim i as integer | ||
|
||
for i = 1 to 4 | ||
print i; | ||
next | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'For loop with new variable | ||
|
||
scope | ||
for i as integer = 20 to 25 | ||
print i; | ||
i = i + 1 | ||
next | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'For loop with step | ||
|
||
scope | ||
for i as double = 0.5 to 5.0 step 0.5 | ||
print i; | ||
next | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'Nested do and for loops | ||
|
||
scope | ||
dim i as integer | ||
|
||
do | ||
for j as integer = i to i + 5 | ||
print j; | ||
next | ||
print !"\n"; | ||
i = i + 1 | ||
loop while i < 5 | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'Exit from nested do loops (do, do) | ||
|
||
scope | ||
dim i as integer | ||
|
||
do while i < 5 | ||
do while i < 3 | ||
print i; | ||
if i >= 2 then | ||
exit do, do | ||
else | ||
i = i + 1 | ||
end if | ||
loop | ||
i = i + 1 | ||
loop | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'Exit from nested loops (for, for) | ||
|
||
scope | ||
for i as integer = 3 to 6 | ||
for j as integer = i to 4 | ||
print j; | ||
exit for, for | ||
next | ||
next | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'For next with iterator | ||
|
||
scope | ||
dim max as integer = 6 | ||
dim s as integer = 2 | ||
|
||
for i as integer = 0 to max step s | ||
print i; | ||
next i | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'Lots of computation with loops | ||
|
||
function pow (b as integer, e as integer) as integer | ||
dim result as integer = 1 | ||
|
||
for i as integer = 1 to e | ||
result = result * b | ||
next i | ||
return result | ||
end function | ||
|
||
scope | ||
dim i as double = 0 - 450 | ||
dim j as integer | ||
|
||
for num as integer = 0 to 20 step 20 | ||
j = num | ||
do while num > j - 19 | ||
i = i + num | ||
num = num - 1 | ||
loop | ||
i = i * 0.5 | ||
next num | ||
|
||
i = pow (i, 3) | ||
print i; | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'Iterator name collision | ||
|
||
scope | ||
dim i as integer | ||
|
||
i = 20 | ||
|
||
for i as double = 0 to 1 step 0.125 | ||
print i; | ||
next i | ||
|
||
print i; | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
' GLOBAL, SCOPE | ||
|
||
scope | ||
dim i as integer | ||
|
||
do while i < 4 | ||
static counter as integer | ||
counter = counter + 1 | ||
print counter; | ||
i = i + 1 | ||
loop | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,14 @@ | |
"GLOBAL", | ||
"IFTHEN" | ||
] | ||
}, | ||
{ | ||
"name": "06", | ||
"stdout": " 1 2 3 4", | ||
"extensions": [ | ||
"GLOBAL", | ||
"SCOPE" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'Reverse string function | ||
|
||
function Reverse_str(s as string) as string | ||
dim str_len as integer = length(s) | ||
dim reversed as string | ||
|
||
dim i as integer | ||
do while i < str_len | ||
reversed = reversed + substr(s, str_len - i, 1) | ||
i = i + 1 | ||
loop | ||
|
||
return reversed | ||
end function | ||
|
||
scope | ||
dim s as string | ||
input s | ||
s = reverse_str(s) | ||
print s; | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'Taylor polynom for log | ||
|
||
function taylor_log(x as double, n as integer) as double | ||
dim result as double | ||
dim x_exp as double = 1 | ||
dim numerator_fraction as double | ||
dim i as integer = 1 | ||
|
||
if x > 1 then | ||
numerator_fraction = (x - 1) / x | ||
|
||
do while i <= n | ||
x_exp = x_exp * numerator_fraction | ||
result = result + x_exp / i | ||
i = i + 1 | ||
loop | ||
else | ||
x = 1 - x | ||
|
||
do while i <= n | ||
x_exp = x_exp * x | ||
result = result - (x_exp / i) | ||
i = i + 1 | ||
loop | ||
end if | ||
return result | ||
end function | ||
|
||
scope | ||
dim d as double | ||
|
||
input d | ||
d = taylor_log(d, 10) | ||
print d; !"\n"; | ||
|
||
input d | ||
d = taylor_log(d, 20) | ||
print d; !"\n"; | ||
end scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters