Skip to content

Instantly share code, notes, and snippets.

View kmicinski's full-sized avatar

Kristopher Micinski kmicinski

View GitHub Profile
@kmicinski
kmicinski / 01-20.rkt
Created January 21, 2026 22:43
CIS352 notes: 01/20
#lang racket
(define x 22)
;; □ -- List introduction: literals, basic operations
'()
'foo
'(x y z) ;; homoiconicity -- the language uses the same
;; representation for syntax / expressions as it does
;; for data.
#lang racket
;; CIS352 -- Spring '26
;; Lecture 2
;; Forms
;; All forms are surrounded by parens, they form S-expressions
;; Here's something to remember from today's class
;; CIS352 notes -- 01/13
#lang racket
;; I can use define to define both values, and also functions
;; this is a value
(define foo 42)
;; Racket is expression-based, meaning that functions evaluate
;; their body expressions, and the result of evaluating any expression
;; is the computation's whole result...
#lang racket
;; Closure Conversion
(define (map f l)
(match l
['() '()]
[`(,hd . ,tl) (cons
(let ([clo-f (vector-ref f 0)]) (clo-f f hd)) ;; (f hd)
(map f tl))]))
@kmicinski
kmicinski / 10-16.rkt
Created October 16, 2025 23:14
Project 3 -- partial solution from class
#lang racket
;; CIS531 Fall '25 Project 1
;; Compiling LVar -> x86-64
(require "irs.rkt") ;; Definition of each IR (please read)
(require "system.rkt") ;; System-specific details
(require "interpreters.rkt")
(provide
typecheck
@kmicinski
kmicinski / 10-07.rkt
Created October 7, 2025 23:21
Code from class: 10/07 (CPS, etc.)
#lang racket
(define (atom? a)
(match a
[(? integer? i) #t]
[(? symbol? x) #t]
[_ #f]))
(define (anf-transform e)
;; e is the expression to be converted
@kmicinski
kmicinski / cps-notes.rkt
Last active October 5, 2025 17:14
CIS531 Project 2 -- `anf-convert`, CPS and CPS Conversion
#lang racket
;; CIS531 -- Fall 2025
;; Kristopher Micinski
;;
;; Notes on CPS Conversion
#;(+ (* (read) 3) (+ 4 5))
;; When we translate constructs like +, *, and other
#lang racket
(require "system.rkt")
;;
;; This file provides detailed documentation of each of the IRs used
;; in the project.
;;
;; Please do not modify this code (doing so will not help you): your
;; passes must conform to these specifications for the autograder to
@kmicinski
kmicinski / left-assoc.rkt
Created September 19, 2025 18:18
Parsing left-associative operators in LL(k) grammars
#lang racket
;; When we say an operator "associates to the left,"
;; we mean that we interpret a construct like
;; 10 - 2 - 2 is interpreted as (10 - 2) - 2 rather
;; than the (incorrect) 10 - (2 - 2). Most typical
;; arithmetic operators like +, *, /, and - associate
;; to the left.
;; Unfortunately, LL parsers do not make this natural
#lang racket
;; Tuesday, April 8, 2025
;; CIS352
(define (λ-expr? e)
(match e
[(? symbol? x) #t]
[`(lambda (,(? symbol? x)) ,(? λ-expr? e-b)) #t]
[`(,(? λ-expr? e0) ,(? λ-expr? e1)) #t]