Skip to content

Instantly share code, notes, and snippets.

@senko
senko / maybe.py
Last active May 2, 2024 18:35
A Pythonic implementation of the Maybe monad
# maybe.py - a Pythonic implementation of the Maybe monad
# Copyright (C) 2014. Senko Rasic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@chrisdone
chrisdone / AnIntro.md
Last active June 18, 2025 08:44
Statically Typed Lisp

Basic unit type:

λ> replTy "()"
() :: ()

Basic functions:

@softwaredoug
softwaredoug / hyperLogLog.c
Created February 3, 2015 04:01
Educational HyperLogLog demo in C
#include "stdio.h"
#include "stdlib.h"
unsigned int max(unsigned int a, unsigned int b) {
return a > b ? a : b;
}
unsigned int bucket(unsigned int val) {
return val & 0xF0000000 >> 28;
}
@viclib
viclib / church_fractions.md
Last active December 23, 2023 13:18
Simplifying division of church-numbers with church-fractions.

Simplifying division of church-numbers with church-fractions.

A church number n can be understood as the act of applying a function to a value n times. That is:

(λ f x . (f (f (f x))))

Can be understood as the church number 3, since it is an action that applies a function, f, to a value, x, 3 times. Here, I will be using "number" as a synonym for "church number" and, thus, a "natural number". Implementing addition, multiplication and exponentiation on church numbers is straightforward. Division is more awkward. Wikipedia, for instance, uses a recursive definition that doesn't have a normal form and is, thus, unsuited for strongly normalizing evaluators. This version is total, but has a huge normal form and works for integers, not naturals. There is a simpler way to define it, extending the same intuition to bu

@jonhoo
jonhoo / README.md
Last active July 19, 2021 10:49
Distributed RWMutex in Go
@bishboria
bishboria / springer-free-maths-books.md
Last active May 10, 2025 04:28
Springer made a bunch of books available for free, these were the direct links