Skip to content

Instantly share code, notes, and snippets.

View kmicinski's full-sized avatar

Kristopher Micinski kmicinski

View GitHub Profile
#lang racket
;; CIS352 -- The Algebra of Programming
;; Spring 2026 -- Kristopher Micinski
;; Introduction:
;;
;; Students often ask (in CIS352): "why learn Racket, a language with
;; an arcane syntax that I might not use outside of this class?" It is
;; a very reasonable question, and today we will answer it directly:
@kmicinski
kmicinski / patterns.rkt
Created February 2, 2026 07:49
Pattern matching
#lang racket
;; CIS352 -- Feb 3, 2026
;; Pattern matching:
;; □ -- Trees, manually
;; □ -- Recursion over trees
;; □ -- Introducing pattern matching
;; □ -- Matching list patterns ("quasipatterns")
;; □ -- Matching predicate patterns
;; □ -- Trees, and algebraic data types generally
#lang racket
;; CIS 352 -- Spring 2026
;; 1/27/26 (I believe)
;; quickanswer.harp-lab.com
;; the define form lets us define funcitons
;; (define (f x y z) e-body)
(define (both-even? n0 n1)
#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-29-notes.rkt
Created January 29, 2026 20:20
Notes: end of class, 1/29
#lang racket
;; CIS352 'S26 -- 1/29 through 2/3
;; □ -- More practice with lambdas
;; □ -- Mapping
;; □ -- Explaining recursion and why it matters
;; □ -- Our first non-list recursive type: trees
;; □ -- Pattern matching
#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.