Skip to content

Instantly share code, notes, and snippets.

quicksort{match} =
{} -> {}
{p, *xs} ->
{*quicksort{l1}, p, *quicksort{l2}} where
{l1, l2} = partition{xs} with {x} -> x < p
@breuleux
breuleux / op.py
Last active December 20, 2015 14:29
Operator precedence parsing
class Operator:
def __init__(self, name, leftp, rightp, merge, fixity, label = None):
self.name = name
self.leftp = leftp
self.rightp = rightp
self.merge = merge
self.fixity = fixity
self.label = label or name
@breuleux
breuleux / exc.py
Created January 14, 2012 18:28
Exception factory
# This code is public domain. Copy away!
exception_classes = dict(
type = TypeError,
value = ValueError,
key = KeyError,
index = IndexError #, ...
)
def Exc(kind):