Skip to content

Instantly share code, notes, and snippets.

@Lapin0t
Lapin0t / mcculloch.py
Created August 24, 2016 15:34
An implementation of McCulloch's machine from Smullyan's book "What Is the Name of This Book?"
from re import match as _m
calcule=(lambda n,machine='machi'
'ne-1': ( lambda m:(lambda
f:(lambda x: x(x))(lambda
x:f(lambda v: (x(x ))(v))))(
lambda f:lambda x:(lambda r:r
.group(1) if r else m[1][x[
0]](f(x[1:])) )(_m(m[0],x)
))(n) if _m( r'[{}]*{}'.
format( ''. join(m[1])
@Lapin0t
Lapin0t / mongodb_match.py
Last active July 9, 2018 10:44
mongoDB-style json querying in python
from functools import reduce
import re
_TYPES = {'string': str, 'int': int, 'object': dict, 'array': list,
'bool': bool, 'null': type(None)}
_OPS = {'$eq': lambda s, d: s == d,
'$gt': lambda s, d: d > s,
'$gte': lambda s, d: d >= s,