Skip to content

Instantly share code, notes, and snippets.

macro $testadd {
case { $$mac $expr } => {
var ident = makeIdent('test', #{ $$mac });
return withSyntax ($ident = [ident]) {
return #{
return $expr + $ident;
}
}
}
}
@tuchida
tuchida / brainfuck.js
Created March 11, 2013 14:49
Brainfuck in sweet.js
macro bf {
case ($body ...) => {
eval('var p = 0, b = [], buf = new Buffer(1);');
_bf($body ...);
}
}
macro _bf {
case (>) => {
eval('p++;');
}
@int3
int3 / gist:4027626
Created November 6, 2012 21:17
Chained comparisons using sweet.js
macro $if {
case ($x ...) => { if (relCar($x ...)) }
}
macro $while {
case ($x ...) => { while (relCar($x ...)) }
}
// naive form:
/*
@puffnfresh
puffnfresh / do.sjs
Created October 4, 2012 04:40
do-notation using sweet.js
macro $do {
case { $y:expr } => {
$y
}
case { $x:ident <- $y:expr $rest ... } => {
λ['>=']($y, function($x) {
return $do { $rest ... }
});
}
}
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2: