This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| ;; Project 0 Tic-tac-toe with Racket | |
| ;; | |
| ;; Please immediately read README.md | |
| (provide board? | |
| next-player | |
| valid-move? | |
| make-move |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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. |
NewerOlder