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,5 @@
# Eat lunch.
lunch: food.eat() for food in ['toast', 'cheese', 'wine'].
# Zebra-stripe a table.
highlight(row) for row, i in table if i % 2 is 0.

View File

@@ -0,0 +1,2 @@
greeting: "Hello CoffeeScript"
difficulty: 0.5

View File

@@ -0,0 +1,9 @@
mood: greatly_improved if singing
if happy and knows_it
claps_hands()
cha_cha_cha().
date: if friday then sue else jill.
expensive ||= do_the_math()

View File

@@ -0,0 +1,3 @@
js: => `alert("Hello JavaScript");`.
js() if 10 > 9

View File

@@ -0,0 +1,9 @@
grade: student =>
if student.excellent_work
"A+"
else if student.okay_stuff
"B"
else
"C"..
eldest: if 24 > 21 then "Liz" else "Ike".

View File

@@ -0,0 +1,2 @@
square: x => x * x.
cube: x => square(x) * x.

View File

@@ -0,0 +1,3 @@
# CoffeeScript on the left, JS on the right.
square: x => x * x.

View File

@@ -0,0 +1,6 @@
song: ["do", "re", "mi", "fa", "so"]
ages: {
max: 10
ida: 9
tim: 11
}

View File

@@ -0,0 +1,11 @@
# Comments start with hash marks.
# Periods mark the end of a block.
left_hand: if raining then umbrella else parasol.
# To signal the beginning of the next expression,
# use "then", or a newline.
left_hand: if raining
umbrella
else
parasol.

View File

@@ -0,0 +1,5 @@
num: 1
change_numbers: =>
num: 2
new_num: 3.
new_num: change_numbers()

View File

@@ -0,0 +1,2 @@
nums: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
three_to_six: nums[3, 6]

View File

@@ -0,0 +1,6 @@
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..."

21
documentation/cs/super.cs Normal file
View File

@@ -0,0 +1,21 @@
Animal: => .
Animal.prototype.move: meters =>
alert(this.name + " moved " + meters + "m.").
Snake: name => this.name: name.
Snake extends new Animal()
Snake.prototype.move: =>
alert("Slithering...")
super(5).
Horse: name => this.name: name.
Horse extends new Animal()
Horse.prototype.move: =>
alert("Galloping...")
super(45).
sam: new Snake("Sammy the Python")
tom: new Horse("Tommy the Palomino")
sam.move()
tom.move()

View File

@@ -0,0 +1,7 @@
switch day
case "Tuesday" then eat_breakfast()
case "Wednesday" then go_to_the_park()
case "Saturday"
if day is bingo_day then go_to_bingo().
case "Sunday" then go_to_church()
else go_to_work().

7
documentation/cs/try.cs Normal file
View File

@@ -0,0 +1,7 @@
try
all_hell_breaks_loose()
cats_and_dogs_living_together()
catch error
print( error )
finally
clean_up().

View File

@@ -0,0 +1,5 @@
while demand > supply
sell()
restock().
while supply > demand then buy().