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
-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) -> |
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
Syntax: | |
Exp u ::= x variable | |
λx.u λ-abstraction | |
u1 u2 application | |
Computation rule: | |
(λx.u2) u1 | |
[u1/x]u2 | |
0 := λf.λx.x |
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 | |
(define (chars n) | |
(string->list (~a n #:min-width 6 #:pad-string "0"))) | |
(define (char->str c) | |
(match c | |
[#\0 "((((((("] | |
[#\1 "(((((("] | |
[#\2 "((((("] |
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 (only-in racket | |
(+ old+))) | |
(define (dechurch n) | |
(n (λ (i) (old+ i 1)) 0)) | |
(define (zero f x) | |
x) |
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 (ant grid mode count) #:transparent) | |
(define freq 20) |
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 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.
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
(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] | |
- |
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 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 |
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 | |
(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)) | |
'(()) |
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 | |
(define-syntax-rule (run x) | |
(begin (printf "> ~a~n" 'x) | |
(printf "~a~n" x))) | |
(define-syntax-rule (baklengs a b c d) | |
(d c b a)) | |
(run (baklengs 2 1 #f if)) |