Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.
This project is maintained by Kray-G
Native function can use an array of Integer or Double.
For that, the type will be int[]
for an array of integer, and dbl[]
for an array of double.
You can also use a multidimensional array like int[][]
.
If you cannot determine it, you can use the type of obj
instead.
In that case, you have to specify the type for a variable which is lvalue of assignment.
See an example below.
native test1(s:obj):str {
var a:obj = s[0]; // `a` will receive a value as an object.
var b:int = a[0][0]; // `b` will receive a value as an integer.
return "a" * b;
}
System.println(test1([[[100]]])); // => "a" is repeated 100 times like "aaa..."
native makeArray(a:int[]):int[] {
for (var i = 0; i < 10; ++i) {
a[i] = i;
}
return a;
}
System.println(makeArray([]));
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
native makeArray(a:dbl[]):dbl[] {
for (var i = 0; i < 10; ++i) {
a[i] = i * 0.1;
}
return a;
}
System.println(makeArray([]));
[0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
native makeArray(a:dbl[][]):dbl[] {
var d:dbl[] = a[0];
for (var i = 0; i < 10; ++i) {
d[i] = i * 0.1;
}
return a;
}
System.println(makeArray([[]]));
[[0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]]
native mapArray(a:dbl[]):dbl[] {
for (var i = 0, n = a.length(); i < n; ++i) {
a[i] = a[i] * a[i];
}
return a;
}
System.println(mapArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
native test1(s:obj):str {
var a:obj = s[0]; // `a` will receive a value as an object.
var b:int = a[0][0]; // `b` will receive a value as an integer.
return "a" * b;
}
System.println(test1([[[100]]])); // => "a" is repeated 100 times like "aaa..."
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa