$ coffee quicksleepsort.coffee 3701 45 292 9 324 45 23 123 1343
9
23
45
crypto = require 'crypto' | |
key = (values) -> | |
crypto.createHash('sha1').update(values.join '-').digest 'hex' | |
memoize = (f, memo = {}) -> | |
-> memo[key [this, arguments...]] ||= f.apply this, arguments | |
fib = memoize (n) -> if n < 2 then n else fib(n-1) + fib(n-2) |
// Coco compiler wrapper for WSH | |
// (must be placed in the same directory as coco.js) | |
// Usage: cscript cowsh.js [--watch] file | |
// inspired by http://kennyj-jp.blogspot.com/2011/01/coffeescriptwindows.html | |
var fs = WScript.CreateObject("Scripting.FileSystemObject"); | |
var scriptPath = WScript.ScriptFullName.slice( | |
0, -WScript.ScriptName.length); | |
var Coco = new new Function( | |
fs.OpenTextFile(scriptPath + "coco.js", 1).ReadAll() |
for(n<-0 to 99)println(Seq(n+1,"Buzz","Fizz","FizzBuzz")(n%3&2|n%5/4)) |