You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
beautiful-racket/beautiful-racket-demo/scriptish-demo/test.rkt

35 lines
607 B
Racket

6 years ago
#lang scriptish-demo
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
6 years ago
thing.bar; // prints #<procedure:...test.rkt:11:12>
6 years ago
thing.bar(3); // prints 18
if ( thing.foo == 42 ) {
// prints "The correct answer is 42"
alert("The correct answer is " + thing.foo);
6 years ago
} else {
alert("Nope");
6 years ago
}
var idx = 0;
while ( idx != 50 ) {
if ( thing.bar(idx) == 35 ) {
// prints "Calamity at 20!"
alert("Calamity at " + idx + "!");
}
idx++;
}