Skip to content

Instantly share code, notes, and snippets.

@gkz
gkz / go.ls
Created July 12, 2012 05:00 — forked from apaleslimghost/go.ls
Cute one-line alternative to function pipe chaining in LiveScript
Object::go = -> fold (|>), this, &
[1 to 10].go do
filter odd
map (^2)
fold1 (+)
#=> 165
#compare:
[1 to 10]
@gkz
gkz / test.clj
Created July 9, 2012 03:06
Functional quicksort in JS
;; QuickSort in Clojure
;; quicksort :: Ord a => [a] -> [a]
(defn quicksort [seq]
(if (emtpy? seq) []
(let [x (first seq)
xs (rest seq)]
(concat (quicksort (filter (fn [v] (<= v x)) xs))
[x]
(quicksort (filter (fn [v] (> v x)) xs))))))
say = -> process.stdout.write it + \\n
targets =
coco: \co
'coffee-script': \cf
'./lib/livescript': \ls
N = 99
o =
@gkz
gkz / LiveScript.ls
Created July 6, 2012 01:45
livescript backcalls example
json <-! $.getJSON \url
results <-! $.get json.url
alert results
@gkz
gkz / gist:2994623
Created June 26, 2012 09:22 — forked from cocodrino/gist:2986585
javascript callbacks to livescript clean code
var phantom = require('phantom');
phantom.create(function(ph) {
return ph.createPage(function(page) {
return page.open("http://www.google.com", function(status) {
console.log("opened google? ", status);
return page.evaluate((function() {
return document.title;
}), function(result) {
console.log('Page title is ' + result);
return ph.exit();