Skip to content

Instantly share code, notes, and snippets.

View robrix's full-sized avatar
🌊
every dot and stroke I paint will be alive

Rob Rix robrix

🌊
every dot and stroke I paint will be alive
View GitHub Profile
My life's yours, love
That's why you'll find, somebody's on my mind
Wants the world to know
And my hair ain't curled
But youre so mean to me, baby, I know youre gonna drive me away
Some call me honey
Like an old sweet song, 'The Lasting Time'
Some tell me "Billie,
@robrix
robrix / autotes.m
Created March 31, 2014 02:51
Not quite as good as I’d hoped, but you can do some fun things with __typeof__.
// cc autotes.m -o autotes -framework Foundation -fobjc-arc && ./autotes
#import <Foundation/Foundation.h>
// use it like lambda(…args…)(…return value…)
#define lambda(...) \
^(__VA_ARGS__) _lambda_body
#define _lambda_body(...) \
{ return __VA_ARGS__; }
((w ord))
((w) (ord))
((word))
((wo rd))
((w o rd))
((w o r d))
((w o r) (d))
((w o) (rd))
((w o) (r d))
((wo) (rd))
@robrix
robrix / sliding-goes-to.c
Last active August 29, 2015 14:00
The sliding goes-to operator in C
#include <stdio.h>
int main(int argc, char *argv[]) {
int i = 10;
while (i \
\
\
\
--> 0) { printf("%i\n", i); }
return EXIT_SUCCESS;
@robrix
robrix / δ.md
Last active August 29, 2015 14:03
Convergence of nullability in the derivative of parser combinators

Interpreting δ as the least fixed point of the nullability equations, ascending from ⊥ = false.

Given S → ϵ ∪ S,

The zeroth iteration is :

δ⁰(S) = ⊥ = false

The first is computed:

@robrix
robrix / parseNull.md
Last active August 29, 2015 14:03
Convergence of parseNull in the derivative of parser combinators

Interpreting parseNull as the least fixed point of the parse null equations, ascending from ⊥ = {}

Given S → ϵ↓{x} ∪ S,

The zeroth iteration is :

parseNull⁰(S) = ⊥ = {}

The first is computed:

@robrix
robrix / &&-truth-table.md
Created February 17, 2015 02:59
The truth table for logical conjunction (&&)
a b a && b
👎 👎 👎
👍 👎 👎
👎 👍 👎
👍 👍 👍
@robrix
robrix / 1.md
Last active August 29, 2015 14:15
The sum is more than the hole of its parts
a b a && b
👎 👎 👎
👍 👎 👎
👎 👍 👎
👍 👍 👍
@robrix
robrix / apomorphisms.hs
Created March 5, 2015 02:32
Apomorphisms in Haskell
newtype Term f = In { out :: f (Term f) }
-- The trivial one
type RCoalgebra1 f a = a -> f (Either (Term f) a)
apo1 :: Functor f => RCoalgebra1 f a -> a -> Term f
apo1 f = In . (fmap fanin) . f
where fanin = either id (apo1 f)
@robrix
robrix / Hammer.hs
Last active March 6, 2016 01:43
Parsing with Derivatives, via GADTs
data Parser a where
Cat :: Parser a -> Parser b -> Parser (a, b)
Alt :: Parser a -> Parser b -> Parser (Either a b)
Rep :: Parser a -> Parser [a]
Map :: Parser a -> (a -> b) -> Parser b
Bnd :: Parser a -> (a -> Parser b) -> Parser b
Lit :: Char -> Parser Char
Ret :: [a] -> Parser a
Nul :: Parser a
Eps :: Parser a