Refine example scripts.
This commit is contained in:
parent
0f2e7e3825
commit
2b1555cff8
@ -5,5 +5,4 @@ print(x[1]);
|
||||
|
||||
x[1] = 5;
|
||||
|
||||
print("x[1] should be 5:");
|
||||
print(x[1]);
|
||||
print(`x[1] should be 5: ${x[1]}`);
|
||||
|
@ -1,4 +1,5 @@
|
||||
print("x should be 78:");
|
||||
|
||||
let x = 78;
|
||||
|
||||
print(x);
|
||||
|
@ -8,4 +8,4 @@ let /* I am a spy in a variable declaration! */ x = 5;
|
||||
|
||||
/* look /* at /* that, /* multi-line */ comments */ can be */ nested */
|
||||
|
||||
/* surrounded by */ x // comments
|
||||
/* surrounded by */ this_is_not_a_comment = true // comments
|
||||
|
@ -4,6 +4,6 @@ fn bob() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
print("bob() should be 3:");
|
||||
let result = bob();
|
||||
|
||||
print(bob());
|
||||
print(`bob() should be 3: ${result}`);
|
||||
|
@ -7,10 +7,8 @@ fn addme(a, b) {
|
||||
a + b; // notice that the last value is returned even if terminated by a semicolon
|
||||
}
|
||||
|
||||
print("addme(a, 4) should be 46:");
|
||||
let result = addme(a, 4);
|
||||
|
||||
print(addme(a, 4));
|
||||
print(!addme(a, 4) should be 46: ${result}``);
|
||||
|
||||
print("a should still be 3:");
|
||||
|
||||
print(a); // should print 3 - 'a' is never changed
|
||||
print(`a should still be 3: ${a}`); // should print 3 - 'a' is never changed
|
||||
|
@ -10,3 +10,5 @@ loop {
|
||||
|
||||
if x <= 0 { break; }
|
||||
}
|
||||
|
||||
export x as foo;
|
||||
|
@ -12,11 +12,11 @@ fn new_mat(x, y) {
|
||||
|
||||
fn mat_gen(n) {
|
||||
let m = new_mat(n, n);
|
||||
let tmp = 1.0 / n.to_float() / n.to_float();
|
||||
let tmp = 1.0 / n / n;
|
||||
|
||||
for i in range(0, n) {
|
||||
for j in range(0, n) {
|
||||
m[i][j] = tmp * (i.to_float() - j.to_float()) * (i.to_float() + j.to_float());
|
||||
m[i][j] = tmp * (i - j) * (i + j);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
import "loop";
|
||||
import "loop" as x;
|
||||
|
||||
print("Module test!");
|
||||
print(`Module test! foo = ${x::foo}`);
|
||||
|
@ -1,4 +1,5 @@
|
||||
print("The result should be 182:");
|
||||
|
||||
let x = 12 + 34 * 5;
|
||||
|
||||
print(x);
|
||||
|
@ -1,4 +1,5 @@
|
||||
print("The result should be 230:");
|
||||
|
||||
let x = (12 + 34) * 5;
|
||||
|
||||
print(x);
|
||||
|
@ -34,4 +34,13 @@ made using multi-line literal
|
||||
|
||||
print(s);
|
||||
|
||||
// Interpolation
|
||||
let s = `This is interpolation ${
|
||||
let x = `within ${let y = "yet another level \
|
||||
of interpolation!"; y} interpolation`;
|
||||
x
|
||||
} within literal string.`;
|
||||
|
||||
print(s);
|
||||
|
||||
print(">>> END <<<");
|
||||
|
Loading…
Reference in New Issue
Block a user