Thank you for your comment

Beau­tiful Racket / racket school 2019

scriptish/test.rkt
#lang scriptish

var x = 42;
var s = "string";

x + x; // prints 84
s + x; // prints "string42"

var thing = {
    "foo" : 42,
    'bar' : function(x) {
        return x + 15;
    }
};

thing.foo; // prints 42
thing.bar; // prints #<procedure:...test.rkt:11:12>
thing.bar(3); // prints 18

if ( thing.foo == 42 ) {
    // prints "The correct answer is 42"
    alert("The correct answer is " + thing.foo);
} else {
    alert("Nope");
}

var idx = 0;
while ( idx != 50 ) {
    if ( thing.bar(idx) == 35 ) {
       // prints "Calamity at 20!"
       alert("Calamity at " + idx + "!");
    }
    idx++;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#lang scriptish

var x = 42;
var s = "string";

x + x; // prints 84
s + x; // prints "string42"

var thing = {
    "foo" : 42,
    'bar' : function(x) {
        return x + 15;
    }
};

thing.foo; // prints 42
thing.bar; // prints #<procedure:...test.rkt:11:12>
thing.bar(3); // prints 18

if ( thing.foo == 42 ) {
    // prints "The correct answer is 42"
    alert("The correct answer is " + thing.foo);
} else {
    alert("Nope");
}

var idx = 0;
while ( idx != 50 ) {
    if ( thing.bar(idx) == 35 ) {
       // prints "Calamity at 20!"
       alert("Calamity at " + idx + "!"); 
    }
    idx++;
}
copy to clipboard
← prev next →