Skip to content

Instantly share code, notes, and snippets.

@amitdev
amitdev / scheme.hs
Created January 14, 2012 10:00
A mini Scheme parser in Haskell (Just for fun)
import Text.ParserCombinators.Parsec
import Monad
data Exp = IntExp Integer
| SymExp String
| SExp [Exp]
deriving (Show)
data Val = IntVal Integer
| SymVal String
@amitdev
amitdev / bench.py
Created June 13, 2013 14:12
Simple benchmark script for lru dict
import sys
import time
import resource
s = sys.argv[1].split('.')
lru = __import__(s[0]).__dict__[s[1]]
m = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
t = time.clock()
from numbers import Number
class M(object):
def __init__(self, val):
self.val = val
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.val)
def __eq__(self, other):
return self.val == other.val