reorganized build-ins and implement a circular queue as an example
This commit is contained in:
@@ -149,7 +149,7 @@ fun parseString(context: Map) {
|
||||
while context.cur < count(context.str)
|
||||
and context.str[context.cur] != '"': {
|
||||
# TODO: Support special characters such as \n, \t ecc
|
||||
buffer = strcat(buffer, context.str[context.cur]);
|
||||
buffer = string.cat(buffer, context.str[context.cur]);
|
||||
context.cur = context.cur + 1;
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ fun parseValue(context: Map) {
|
||||
val, err = parseFalse(context);
|
||||
else {
|
||||
val = none;
|
||||
err = strcat("Unexepected character \"", c, "\" where a value was expected");
|
||||
err = string.cat("Unexepected character \"", c, "\" where a value was expected");
|
||||
}
|
||||
return val, err;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
json = import("json.noja");
|
||||
utils = import("utils.noja");
|
||||
utils = import("../utils.noja");
|
||||
|
||||
assert(json.parse("null") == none);
|
||||
assert(json.parse("true") == true);
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
fun compareAny(A, B) {
|
||||
|
||||
fun compareLists(A: List, B: List) {
|
||||
n = count(A);
|
||||
if n != count(B):
|
||||
return false;
|
||||
|
||||
i = 0;
|
||||
while i < n: {
|
||||
if not compareAny(A[i], B[i]):
|
||||
return false;
|
||||
i = i + 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
T = type(A);
|
||||
|
||||
if T != type(B):
|
||||
return false;
|
||||
|
||||
if T == List:
|
||||
return compareLists(A, B);
|
||||
|
||||
if T == Map:
|
||||
error("Maps aren't supported yet!");
|
||||
|
||||
return A == B;
|
||||
}
|
||||
|
||||
assert(compareAny(1, 2) == false);
|
||||
assert(compareAny([], []) == true);
|
||||
assert(compareAny([], [1]) == false);
|
||||
assert(compareAny([1, 2, 3], [1, 2, 3]) == true);
|
||||
assert(compareAny([1, 2, 3], [1, 2, 4]) == false);
|
||||
assert(compareAny([1, 2, 3], [1, 2, 3, 4]) == false);
|
||||
Reference in New Issue
Block a user