Skip to content

Instantly share code, notes, and snippets.

View kmicinski's full-sized avatar

Kristopher Micinski kmicinski

View GitHub Profile
#lang racket
;; CIS352 'S26 -- 1/29 through 2/3
;; (There is a lot of material here, we will not cover it all today.)
;; □ -- More practice with lambdas
;; □ -- Mapping
;; □ -- Explaining recursion and why it matters
;; □ -- Our first non-list recursive type: trees
;; □ -- Pattern matching
#lang racket
;; Project 0 Tic-tac-toe with Racket
;;
;; Please immediately read README.md
(provide board?
next-player
valid-move?
make-move
@kmicinski
kmicinski / 01-28-oh-1.rkt
Created January 28, 2026 20:01
Office Hours Code
#lang racket
;; Define a function that evaluates to #t if
;; the list l contains the number 7
;;
;; - what do we do when l is '()
;; - what do we do when l is (cons hd tl)
(define (contains-7 l)
(if (empty? l)
#f
#lang racket
;; Notes, 1/22
;; f is a function from α → bool (i.e., a predicate)
;; l is list of αs
;; we return the number of elements in l such that
;; they satisfy the predicate f
;; (count even? '(0 1 2 3 4)) ;; => 3
#;(define (count f l)
@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