This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 := λf.λx.x | |
1 := λf.λx.f x | |
2 := λf.λx.f (f x) | |
succ := λn.λf.λx.f (n f x) | |
+ := λa.λb.a succ b | |
* := λa.λb.a (b succ) 0 | |
pair := λa.λb.λf.f a b | |
fst := λc.c (λa.λb.a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require "mk.rkt") | |
(define (conso a d c) | |
(== `(,a . ,d) c)) | |
(define (caro c a) | |
(fresh (d) | |
(conso a d c))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require "mk.rkt") | |
;; mostly https://gist.github.com/swannodette/997140 | |
;; probably sprinkled with broken | |
(define (findo x l o) | |
(fresh (s v d) | |
(symbolo x) | |
(== `((,s : ,v) . ,d) l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/async-channel) | |
(provide spawn ! ? self) | |
;; kind of actors built from channels and parameters | |
;; which is not to say that that is a good idea | |
(define self-param (make-parameter #f)) | |
(define (self) (or (self-param) (error))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(struct functor (fmap)) | |
(struct monad functor (unit bind then)) | |
(define (make-monad unit bind (then #f)) | |
(monad (λ (f m) (bind m (λ (x) (unit (f x))))) | |
unit | |
bind |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require (except-in 2htdp/universe left right) | |
2htdp/image) | |
(struct pos (x y) #:transparent) | |
(struct ant (pos dir) #:transparent) | |
(struct world (a b n) #:transparent) | |
(define dirs | |
(let* ([i (overlay (triangle 8 "solid" "black") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
datatype nat = z | s of nat | |
fun fold _ zv z = zv | |
| fold sf zv (s n) = sf (fold sf zv n) | |
fun pz _ = z | |
fun ps g h = h (g s) | |
fun id x = x | |
fun p n = (fold ps pz n) id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang reader "xmaslang.rkt" | |
-+ | |
+/|+5++3 1 1 <x +2x> | |
$->#2<x 1>s 1<i+s i> | |
+||#5<x ->x<y+$x z 100 <k - z k | |
>y> > <x $x a 0 <b +a b> > | - | |
$ ->#10<x#x>x0<y+x$y z0<y+y z>> | |
$ ->->#30<x+x1> <x% | |
$->#10<a*a$=?->#<foo?=foo*2 | |
4<bar*+foo bar bar>[-20 15] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require 2htdp/image) | |
(define-syntax structs | |
(syntax-rules () | |
[(_) (begin)] | |
[(_ (name args ...) rest ...) (begin (struct name (args ...) #:transparent) | |
(structs rest ...))])) | |
(structs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)])) |
OlderNewer