- Pebble is a dialect of Lisp, and translated to CoffeeScript.
;(def name val)
;(fn param body)
(def square (fn [x] (* x x)))
(square 4)
((fn [x] (* x x)) 4)
(.map [0 1 2] #(- _0 1))
(.map [0 1 2] (fn [_0 _1 _2 _3 _4 _5] (- _0 1)))
;(do & bodys)
(def i
(do
(console.log i)
(+ i 1)))
;(if & clauses)
(if true "alway"
false "never"
false "and more"
"default")
;(loop name? bindings body)
(loop [i 0]
(if (> i 10) i
(recur
(do
(console.log i)
(+ i 1)))))
;nested loop
(loop recur1 [m m]
...
(loop recur2 [n n]
...
(recur1 ...) ...) ...)
(try
(throw "hoge")
..
(catch e ..)
(finally ..))
(def obj {:a 0 :b 1 :c 2 :fn #(_0)})
(def a "a")
(. obj a)
(. obj "a")
(. obj "fn" "hello")
(.fn obj)
(.fn obj "hello")
(:a obj)
(def ary [1 9 8 4])
(. ary 0)
(:1 ary)
(. console log :helloPebble)
(.log console :helloPebble)
(defmacro when
([test] `(alert :Error))
([test & more] `(if ,test (do ,@more))))
(when a b c d)
:
.
new
== !=
> >= < <=
+ - * / %
& | ^ ~ << >> >>>
and or not ?
of typeof instanceof delete
(.log console
((coffee "
do ->
title = document.title
`function(script){
return [title, 'Hello ' + script].join(': ');
}`
")
"CoffeeScript/JavaScript"))
- coffee-script.js <cofee-script>
Creative Commons CC BY-SA 3.0
Copyright © 2013 Legokichi Duckscallion
Legokichi Duckscallion