Skip to content

Instantly share code, notes, and snippets.

@keller
Last active March 24, 2022 17:08
Show Gist options
  • Save keller/8aa87814c120e725f9ed6c223642e981 to your computer and use it in GitHub Desktop.
Save keller/8aa87814c120e725f9ed6c223642e981 to your computer and use it in GitHub Desktop.
#lang racket
(define TRUE (λ (x) (λ (y) x)) )
(define FALSE (λ (x) (λ (y) y)) )
(define ZERO (λ (f) (λ (a) a)))
(define ONE (λ (f) (λ (a) (f a))))
(define TWO (λ (f) (λ (a) (f (f a)))))
(define THREE (λ (f) (λ (a) (f (f (f a))))))
(define FIVE (λ (f) (λ (a) (f (f (f (f (f a))))))))
(define SUCC (λ (n) (λ (f) (λ (a) (f ((n f) a)) ))))
(define MULT (λ (x) (λ (y) (λ (f) (x (y f))))))
(define TEN ((MULT FIVE) TWO))
(define FIFTEEN ((MULT FIVE) THREE))
(define HUNDRED ((MULT TEN) TEN))
(define PAIR (λ (x) (λ (y) (λ (f) ((f x) y) ))))
(define CAR (λ (p) (p (λ (x) (λ (y) x)))))
(define CDR (λ (p) (p (λ (x) (λ (y) y)))))
(define PHI (λ (p) ((PAIR (CDR p)) (SUCC (CDR p))) ))
(define PRED (λ (n) (CAR ((n PHI) ((PAIR ZERO) ZERO))) ))
(define SUB (λ (x) (λ (y) ((y PRED) x) )))
(define IS_0 (λ (n) ((n (λ (x) FALSE)) TRUE)))
(define LEQ (λ (x) (λ (y) (IS_0 ((SUB x) y)))))
(define Y (λ (f) ((λ (x) (f (λ (y) ((x x) y))))
(λ (x) (f (λ (y) ((x x) y)))))))
(define MOD (Y (λ (f) (λ (x) (λ (y)
((((LEQ y) x)
(λ (z) (((f ((SUB x) y)) y) z)))
x))))))
(define to_num (λ (n) ((n (λ (x) (+ x 1))) 0)))
(define (FIZZ) (displayln "FIZZ"))
(define (BUZZ) (displayln "BUZZ"))
(define (FIZZBUZZ) (displayln "FIZZBUZZ"))
(and
((HUNDRED (λ (x)
((FALSE
((
((IS_0 ((MOD x) FIFTEEN)) FIZZBUZZ)
(((IS_0 ((MOD x) THREE)) FIZZ)
(((IS_0 ((MOD x) FIVE)) BUZZ)
(λ () (displayln (to_num x))))))))
(SUCC x))
)) ONE)
(void))
#lang racket
(and((λ(n)((λ(d)((λ(f)((λ(b)((λ(fb)(((((λ(x)(λ(y)(λ(z)(x(y z)))))(((λ(x)(λ(y)(λ(z)(x(y z)))))(λ(x)(λ(y)(x(x(x(x(x y))))))))(λ(x)(λ(y)(x(x y))))))(((λ(x)(λ(y)(λ(z)(x(y z)))))(λ(x)(λ(y)(x(x(x(x(x y))))))))(λ(x)(λ(y)(x(x y))))))(λ(x)(((λ(x)(λ(y)y))(((((λ(x)((x(λ(x)(λ(x)(λ(y)y))))(λ(x)(λ(y)x))))((((λ(x)((λ(y)(x(λ(z)((y y)z))))(λ(y)(x(λ(z)((y y)z))))))(λ(w)(λ(x)(λ(y)(((((λ(x)(λ(y)((λ(x)((x(λ(x)(λ(x)(λ(y)y))))(λ(x)(λ(y)x))))(((λ(x)(λ(y)((y(λ(x)((λ(x)(x(λ(y)(λ(z)y))))((x(λ(x)(((λ(x)(λ(y)(λ(z)((z x)y))))((λ(x)(x(λ(y)(λ(z)z))))x))((λ(x)(λ(y)(λ(z)(y((x y)z)))))((λ(x)(x(λ(y)(λ(z)z))))x)))))(((λ(x)(λ(y)(λ(z)((z x)y))))(λ(x)(λ(y)y)))(λ(x)(λ(y)y)))))))x)))x)y))))y)x)(λ(z)(((w(((λ(x)(λ(y)((y(λ(x)((λ(x)(x(λ(y)(λ(z)y))))((x(λ(x)(((λ(x)(λ(y)(λ(z)((z x)y))))((λ(x)(x(λ(y)(λ(z)z))))x))((λ(x)(λ(y)(λ(z)(y((x y)z)))))((λ(x)(x(λ(y)(λ(z)z))))x)))))(((λ(x)(λ(y)(λ(z)((z x)y))))(λ(x)(λ(y)y)))(λ(x)(λ(y)y)))))))x)))x)y))y)z)))x)))))x)(((λ(x)(λ(y)(λ(z)(x(y z)))))(λ(x)(λ(y)(x(x(x(x(x y))))))))(λ(x)(λ(y)(x(x(x y))))))))(λ()(d fb)))((((λ(x)((x(λ(x)(λ(x)(λ(y)y))))(λ(x)(λ(y)x))))((((λ(x)((λ(y)(x(λ(z)((y y)z))))(λ(y)(x(λ(z)((y y)z))))))(λ(w)(λ(x)(λ(y)(((((λ(x)(λ(y)((λ(x)((x(λ(x)(λ(x)(λ(y)y))))(λ(x)(λ(y)x))))(((λ(x)(λ(y)((y(λ(x)((λ(x)(x(λ(y)(λ(z)y))))((x(λ(x)(((λ(x)(λ(y)(λ(z)((z x)y))))((λ(x)(x(λ(y)(λ(z)z))))x))((λ(x)(λ(y)(λ(z)(y((x y)z)))))((λ(x)(x(λ(y)(λ(z)z))))x)))))(((λ(x)(λ(y)(λ(z)((z x)y))))(λ(x)(λ(y)y)))(λ(x)(λ(y)y)))))))x)))x)y))))y)x)(λ(z)(((w(((λ(x)(λ(y)((y(λ(x)((λ(x)(x(λ(y)(λ(z)y))))((x(λ(x)(((λ(x)(λ(y)(λ(z)((z x)y))))((λ(x)(x(λ(y)(λ(z)z))))x))((λ(x)(λ(y)(λ(z)(y((x y)z)))))((λ(x)(x(λ(y)(λ(z)z))))x)))))(((λ(x)(λ(y)(λ(z)((z x)y))))(λ(x)(λ(y)y)))(λ(x)(λ(y)y)))))))x)))x)y))y)z)))x)))))x)(λ(x)(λ(y)(x(x(x y)))))))(λ()(d f)))((((λ(x)((x(λ(x)(λ(x)(λ(y)y))))(λ(x)(λ(y)x))))((((λ(x)((λ(y)(x(λ(z)((y y)z))))(λ(y)(x(λ(z)((y y)z))))))(λ(w)(λ(x)(λ(y)(((((λ(x)(λ(y)((λ(x)((x(λ(x)(λ(x)(λ(y)y))))(λ(x)(λ(y)x))))(((λ(x)(λ(y)((y(λ(x)((λ(x)(x(λ(y)(λ(z)y))))((x(λ(x)(((λ(x)(λ(y)(λ(z)((z x)y))))((λ(x)(x(λ(y)(λ(z)z))))x))((λ(x)(λ(y)(λ(z)(y((x y)z)))))((λ(x)(x(λ(y)(λ(z)z))))x)))))(((λ(x)(λ(y)(λ(z)((z x)y))))(λ(x)(λ(y)y)))(λ(x)(λ(y)y)))))))x)))x)y))))y)x)(λ(z)(((w(((λ(x)(λ(y)((y(λ(x)((λ(x)(x(λ(y)(λ(z)y))))((x(λ(x)(((λ(x)(λ(y)(λ(z)((z x)y))))((λ(x)(x(λ(y)(λ(z)z))))x))((λ(x)(λ(y)(λ(z)(y((x y)z)))))((λ(x)(x(λ(y)(λ(z)z))))x)))))(((λ(x)(λ(y)(λ(z)((z x)y))))(λ(x)(λ(y)y)))(λ(x)(λ(y)y)))))))x)))x)y))y)z)))x)))))x)(λ(x)(λ(y)(x(x(x(x(x y)))))))))(λ()(d b)))(λ()(d(n x))))))))((λ(x)(λ(y)(λ(z)(y((x y)z)))))x))))(λ(x)(λ(y)(x y)))))"FIZZBUZZ"))"BUZZ"))"FIZZ"))displayln))(λ(n)((n(λ(x)(+ x 1)))0)))(void))
docker run --rm racket/racket:8.0 sh -c "curl -s -o fizz.rkt https://gist.githubusercontent.com/keller/8aa87814c120e725f9ed6c223642e981/raw/fizz_expanded.rkt && racket fizz.rkt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment