-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: error reporting for inbuilt funcs
- Loading branch information
1 parent
72a4111
commit aa417e5
Showing
3 changed files
with
44 additions
and
15 deletions.
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,24 @@ | ||
fun isEven(n) { | ||
while (n >= 2) { | ||
n = n - 2; | ||
} | ||
return n == 0; | ||
} | ||
|
||
fun filterEven(arr) { | ||
var oddArr = []; | ||
for (var i = 0; i < len(arr); i = i + 1) { | ||
if (isEven(arr[i])) { | ||
oddArr = oddArr + [arr[i]]; | ||
} | ||
} | ||
return oddArr; | ||
} | ||
|
||
var arr = [1, 2, 3, 4, 5]; | ||
print filterEven(arr); | ||
print len(arr, 0); | ||
|
||
// [2.0, 4.0] | ||
// RuntimeError: Expected 1 arguments but got 2. | ||
// [line 20] |
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