1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

documentation waypoint

This commit is contained in:
Jeremy Ashkenas 2009-12-21 11:41:45 -05:00
parent dcc70e5ab0
commit c7fa9c320a
42 changed files with 1026 additions and 53 deletions

View file

@ -0,0 +1,16 @@
(function(){
var lunch;
var a = ['toast', 'cheese', 'wine'];
var d = [];
for (var b=0, c=a.length; b<c; b++) {
var food = a[b];
d[b] = food.eat();
}
lunch = d;
var e = table;
for (var f=0, g=e.length; f<g; f++) {
var row = e[f];
var i = f;
i % 2 === 0 ? highlight(row) : null;
}
})();

View file

@ -0,0 +1,4 @@
(function(){
var greeting = "Hello CoffeeScript";
var difficulty = 0.5;
})();

View file

@ -0,0 +1,12 @@
(function(){
var mood;
if (singing) {
mood = greatly_improved;
}
if (happy && knows_it) {
claps_hands();
cha_cha_cha();
}
var date = friday ? sue : jill;
expensive = expensive || do_the_math();
})();

View file

@ -0,0 +1,8 @@
(function(){
var js = function() {
return alert("Hello JavaScript");
};
if (10 > 9) {
js();
}
})();

View file

@ -0,0 +1,12 @@
(function(){
var grade = function(student) {
if (student.excellent_work) {
return "A+";
} else if (student.okay_stuff) {
return "B";
} else {
return "C";
}
};
var eldest = 24 > 21 ? "Liz" : "Ike";
})();

View file

@ -0,0 +1,3 @@
(function(){
})();

View file

@ -0,0 +1,8 @@
(function(){
var square = function(x) {
return x * x;
};
var cube = function(x) {
return square(x) * x;
};
})();

View file

@ -0,0 +1,5 @@
(function(){
var square = function(x) {
return x * x;
};
})();

View file

@ -0,0 +1,8 @@
(function(){
var song = ["do", "re", "mi", "fa", "so"];
var ages = {
max: 10,
ida: 9,
tim: 11
};
})();

View file

@ -0,0 +1,4 @@
(function(){
var left_hand = raining ? umbrella : parasol;
left_hand = raining ? umbrella : parasol;
})();

View file

@ -0,0 +1,9 @@
(function(){
var num = 1;
var change_numbers = function() {
num = 2;
var new_num = 3;
return new_num;
};
var new_num = change_numbers();
})();

View file

@ -0,0 +1,4 @@
(function(){
var nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var three_to_six = nums.slice(3, 6 + 1);
})();

View file

@ -0,0 +1,8 @@
(function(){
var moby_dick = "Call me Ishmael. Some years ago --\
never mind how long precisely -- having little\
or no money in my purse, and nothing particular\
to interest me on shore, I thought I would sail\
about a little and see the watery part of the\
world...";
})();

28
documentation/js/super.js Normal file
View file

@ -0,0 +1,28 @@
(function(){
var Animal = function() {
};
Animal.prototype.move = function(meters) {
return alert(this.name + " moved " + meters + "m.");
};
var Snake = function(name) {
this.name = name;
};
Snake.prototype = new Animal();
Snake.prototype.move = function() {
alert("Slithering...");
return this.constructor.prototype.move.call(this, 5);
};
var Horse = function(name) {
this.name = name;
};
Horse.prototype = new Animal();
Horse.prototype.move = function() {
alert("Galloping...");
return this.constructor.prototype.move.call(this, 45);
};
var sam = new Snake("Sammy the Python");
var tom = new Horse("Tommy the Palomino");
sam.move();
tom.move();
})();

View file

@ -0,0 +1,13 @@
(function(){
if (day === "Tuesday") {
eat_breakfast();
} else if (day === "Wednesday") {
go_to_the_park();
} else if (day === "Saturday") {
day === bingo_day ? go_to_bingo() : null;
} else if (day === "Sunday") {
go_to_church();
} else {
go_to_work();
}
})();

10
documentation/js/try.js Normal file
View file

@ -0,0 +1,10 @@
(function(){
try {
all_hell_breaks_loose();
cats_and_dogs_living_together();
} catch (error) {
print(error);
} finally {
clean_up();
}
})();

View file

@ -0,0 +1,9 @@
(function(){
while (demand > supply) {
sell();
restock();
}
while (supply > demand) {
buy();
}
})();