Skip to content

Instantly share code, notes, and snippets.

Pondering language design...


Pondering language design...
View GitHub Profile
zmactep /
Created Aug 20, 2017
Number encodings

Alternative to the Church, Scott and Parigot encodings of data on the Lambda Calculus.

When it comes to encoding data on the pure λ-calculus (without complex extensions such as ADTs), there are 3 widely used approaches.

Church Encoding

The Church Encoding, which represents data structures as their folds. Using Caramel’s syntax, the natural number 3 is, for example. represented as:

0 c0 = (f x -> x)
1 c1 = (f x -> (f x))
2 c2 = (f x -> (f (f x)))
mujahidk /
Created Dec 23, 2016
List files using ls and size in MB (mega bytes)
# :)
ls -l --block-size=M
zehnpaard / simple-compojure.core.clj
Created Oct 30, 2016
Simple Compojure Demo with GET/POST forms
View simple-compojure.core.clj
(ns simple-compojure.core
[ring.adapter.jetty :refer [run-jetty]]
[ring.middleware.params :as p]
[simple-compojure.middleware :as m]
[simple-compojure.routes :as r]
(def app
(-> r/routes
andymatuschak /
Last active Nov 11, 2022
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

View Makefile
# Hello, and welcome to makefile basics.
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
# Once you're done here, go to
# to learn SOOOO much more.
chaitanyagupta /
Last active Nov 27, 2022
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. do their work at read-time.


taken from

The system

The minisystem goes like this:

  • Say what you do and roll a number of d6s.
  • If the sum of your roll is higher than the opposing roll (either another player or the DM), the thing you wanted to happen, happens.
  • The number of the d6s you roll is determined by the level of skill you have.
coolaj86 /
Last active Dec 11, 2015
An installer for all the things that aren't included in Ubuntu for legal reasons, but are necessary for normal computer use - Adobe Reader, MP3, DVD, Blu-Ray, fonts, etc.
# Usage: sudo apt-get install -yqq curl; curl -L -s | sudo bash
#alias sagi="apt-get install --yes --quiet" # normall sudo apt-get, but this is already root
#alias sagid="apt-get install --yes --quiet --download-only" # same as above
arvearve / gist:4158578
Created Nov 28, 2012
Mathematics: What do grad students in math do all day?
View gist:4158578

Mathematics: What do grad students in math do all day?

by Yasha Berchenko-Kogan

A lot of math grad school is reading books and papers and trying to understand what's going on. The difficulty is that reading math is not like reading a mystery thriller, and it's not even like reading a history book or a New York Times article.

The main issue is that, by the time you get to the frontiers of math, the words to describe the concepts don't really exist yet. Communicating these ideas is a bit like trying to explain a vacuum cleaner to someone who has never seen one, except you're only allowed to use words that are four letters long or shorter.

What can you say?