Skip to content

Instantly share code, notes, and snippets.

#lang racket
(provide (rename-out (module-begin #%module-begin))
#%app)
(define (push stack x)
(cons x stack))
(define (add stack)
(match stack
[(list b a xs ...) (cons (+ a b) xs)]))
@Glorp
Glorp / goats.erl
Created April 8, 2014 16:46
Game of lifey. Like way concurrent and broken. Don't remember exactly how to anything with this.
-module(goats).
-compile(export_all).
cell(Pos, Vis) ->
receive
{neighbours, Cells} -> setupDeadCell(Pos, Cells, 0, Vis);
Stuff -> io:format("cell, ~p~n", [Stuff]), false = true
end.
setupDeadCell(Pos, Neighbours, AliveNeighbours, Vis) ->
Syntax:
Exp u ::= x variable
λx.u λ-abstraction
u1 u2 application
Computation rule:
(λx.u2) u1
[u1/x]u2
0 := λf.λx.x
#lang racket
(define (chars n)
(string->list (~a n #:min-width 6 #:pad-string "0")))
(define (char->str c)
(match c
[#\0 "((((((("]
[#\1 "(((((("]
[#\2 "((((("]
#lang racket
(require (only-in racket
(+ old+)))
(define (dechurch n)
(n (λ (i) (old+ i 1)) 0))
(define (zero f x)
x)
#lang racket
(require (except-in 2htdp/universe left right)
2htdp/image)
(struct pos (x y) #:transparent)
(struct ant (pos dir) #:transparent)
(struct world (ant grid mode count) #:transparent)
(define freq 20)
@Glorp
Glorp / turm.rkt
Last active August 29, 2015 14:12
#lang racket
(require (except-in 2htdp/universe left right up down)
2htdp/image
lang/posn
(only-in racket (struct struckt)))
(define-syntax-rule (struct (name params ...))
(struckt name (params ...) #:transparent))
;; column vector for position in 3D space
This file has been truncated, but you can view the full file.
(slide "start")
------------------------------------------------------------
Existential Lambda Calculus
or: Less Unitype, More Unicode
(start-lamb "C-e"
"C-k"
"C-S-d")
Standard ML of New Jersey v110.76 [built: Sun Jul 14 09:59:19 2013]
-
@Glorp
Glorp / nums.sml
Created May 14, 2015 14:15
1-9 and things
datatype exp = Num of int
| Plus of exp * int
| Minus of exp * int
fun eval (Num n) = n
| eval (Plus (a, b)) = eval a + b
| eval (Minus (a, b)) = eval a - b
fun expstr (Num n) = Int.toString n
| expstr (Plus (a, b)) = expstr a ^ "+" ^ Int.toString b
@Glorp
Glorp / nums.rkt
Created May 14, 2015 14:16
things and 1-9
#lang racket
(define (evalexp e [n (+ (length e) 1)])
(match e
[`(|| . ,xs) (evalexp xs (string->number (~a (length e) n)))]
[`(,x . ,xs) ((hash-ref (hash '+ + '- -) x) (evalexp xs) n)]
[`() n]))
(define (perms len elms)
(foldr (λ (_ res) (append-map (λ (p) (map (λ (e) `(,e . ,p)) elms)) res))
'(())