Skip to content

Instantly share code, notes, and snippets.

#IfWinActive SmoothDraw
1::SelectColor(0)
2::SelectColor(1)
3::SelectColor(2)
4::SelectColor(3)
5::SelectColor(4)
6::SelectColor(5)
rInt :: String -> Int
rInt = read
count :: String -> Int
count [] = 1
count (a:[]) = 1
count (a:b:c) = count (b:c) + twice
where
twice = if isValid (a:b:[]) then count c else 0
isValid s = (rInt s) < 27
import Data.List
import Data.Maybe
type Point = (Int, Int)
data Line = Line Point Point
deriving (Eq, Show, Ord)
fx (Line (n, _) _) = n
fy (Line (_, n) _) = n
@jb55
jb55 / gist:716279
Created November 26, 2010 04:19
The Clay compiler is impressive
main() {
var a = map(Char, [78, 111, 119, 32, 72, 105, 113, 105, 110, 103, 0]);
println(Type(a));
println(a);
}
> Array[Char, 11]
> Now Hiring
@jb55
jb55 / fact.clay
Created November 27, 2010 06:30
Static factorial in clay
procedure fact;
overload fact(static 0) = 1;
[n | n > 0]
overload fact(static n) = fact(static n - 1) * n;
main() {
var x = fact(static 4); // == 24, calculated at compile time
}
###############################
gcd(a, b) = if (b == 0) a else gcd(b, a % b);
----------------------------------^
main() {
###############################
rational.clay(2,34): error: type propagation failed due to recursion without base case
compilation context:
var titan = titan || {}
//===----------------------------------------------------------------------===//
// Data
//===----------------------------------------------------------------------===//
titan.tiles = [
{ name: 'grass' },
];
import Control.Arrow
import Control.Monad
import Control.Monad.Random
import Data.List
import Data.Map
import Data.Maybe
-- A monad which represents a random integer from 1-6
die :: (RandomGen g) => Rand g Int
die = getRandomR (1,6)
DEPS=$(cat urls.txt | grep -o "\w\+\.\w\+$")
redo-ifchange $DEPS
@jb55
jb55 / gist:945731
Created April 28, 2011 03:13
replace nginx with connect
var connect = require('connect')
, proxy = require('http-proxy')
function redirect(loc) {
return connect.createServer(function(req, res){
res.writeHead(301, { "Location": loc });
res.end();
});
}