Skip to content

Instantly share code, notes, and snippets.

View kmicinski's full-sized avatar

Kristopher Micinski kmicinski

View GitHub Profile
;; Challenge: find all the bugs in this small functional compiler
#lang racket
(provide (all-defined-out))
(define verbose-mode (make-parameter #t))
(define i-am-a-mac (make-parameter #f))
;;
;; Our compiler will have several layers
#lang racket
;; v0.0 April 8, 2024 -- WORKING NOTES (could have bugs!)
;; Apply/Eval Refactoring -- Semantics Homework
;;
;; Kris Micinski (kkmicins@syr.edu and krismicinski@gmail.com)
;;
;; Warning: may be buggy, please contact kris if you notice
;; obvious bugs.
(provide (all-defined-out))
#lang racket
;; The Church-encoded number N is represented as:
;; - A function (λ (f) ...) which takes a function f
;; - Returns a function which accepts an argument x
;; and applies f N times to x
;; two, Church-encoded as a *Racket* lambda
(λ (f) (λ (x) (f (f x))))
#lang racket
;; The Church-encoded number N is represented as:
;; - A function (λ (f) ...) which takes a function f
;; - Returns a function which accepts an argument x
;; and applies f N times to x
;; two, Church-encoded as a *Racket* lambda
(λ (f) (λ (x) (f (f x))))
#lang racket
;; CIS352 -- 3/19/2024
;; Exam Solutions
;; Version A
;; (1a)
(define (count-n lst n)
(match lst
#lang racket
;; PRACTICE Midterm 1 solutions
;; Part (a)
(define (mul-list l k)
(if (empty? l)
'()
(cons (* (first l) k) (mul-list (rest l) k))))
#lang racket
;; Some example λ calculus terms in Racket
;; ID (identity) applied to ID
;; ((λ (x) x) (λ (x) x))
;; can't run this, y is free--but I can still β reduce it
;;((λ (x) y) (λ (z) y))
;; ⟶β y <-- error, in Racket, because we don't know what y is
;; CIS352 -- Feb 27, 2023
;; Definitional interpreters for Scheme (warmup to e3)
#lang racket
(define (expr? e)
(match e
[(? number? n) #t]
[`(+ ,(? expr? e0) ,(? expr? e1)) #t]
[(? symbol? x) #t]
;; (let ([x (+ y z)]) x)
;; Exercise 2
;; CIS 352 -- Spring 2024
#lang racket
(provide (all-defined-out))
;;
;; Maps
;;
;; Exercise 2
;; CIS 352 -- Spring 2024
#lang racket
(provide (all-defined-out))
;;
;; Maps
;;