Created
February 8, 2024 14:39
-
-
Save SHoltzen/8669eaa2ec714cb9564ed74d43a17599 to your computer and use it in GitHub Desktop.
Quiz #1 for CS4400 starter code
This file contains 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 plait | |
; --------------------------- | |
; - Problem 1: Short answer - | |
; --------------------------- | |
; -------------- | |
; - Problem 1a - | |
; -------------- | |
(define-type Exp | |
[numE (n : Number)] | |
[plusE (left : Exp) (right : Exp)] | |
[varE (name : Symbol)] | |
[let1E (var : Symbol) | |
(assignment : Exp) | |
(body : Exp)]) | |
(define my-exp-subst (error 'not-implemented "implement me!")) | |
; -------------- | |
; - Problem 1b - | |
; -------------- | |
;; Provide hypothetical changes to the host semantics. | |
#| Proposed change 1: | |
[Describe change 1...] | |
|# | |
#| Proposed change 2: | |
[Describe change 2...] | |
|# | |
#| Proposed change 3: | |
[Describe change 3...] | |
|# | |
; -------------- | |
; - Problem 1c - | |
; -------------- | |
(define-type Pokemon | |
(pre-evo (name : String) (evo : Pokemon)) | |
(final-evo (name : String))) | |
(define (evolve p) | |
(error 'not-implemented "implement me!")) | |
; -------------- | |
; - Problem 1d - | |
; -------------- | |
#| Evaluation of (succ z): | |
[Evaluate (succ z)...] | |
|# | |
#| Evaluation of (succ (succ z)): | |
[Evaluate (succ (succ z))...] | |
|# | |
#| What do you think the pattern is? | |
[Answer here...] | |
|# | |
; --------------------------- | |
; - Problem 2: Fix the code - | |
; --------------------------- | |
#| What is wrong with the code? | |
[Explain here...] | |
|# | |
; Fix has-pre-evo to show the correct behavior: | |
(define-type-alias Pokedex (Listof Pokemon)) | |
(define (has-pre-evo pkmn dex) | |
(type-case Pokedex dex | |
[empty (error 'NoPkmn "dex is empty!!")] | |
[(cons p l) (if (equal? (pre-evo-evo p) pkmn) p (has-pre-evo pkmn l))])) | |
; ------------------------------------ | |
; - Problem 3: From parsing and back - | |
; ------------------------------------ | |
(define-type Tree | |
(leaf [val : Number]) | |
(node [val : Number] | |
[left : Tree] | |
[right : Tree])) | |
; -------------- | |
; - Problem 3a - | |
; -------------- | |
(define (tree-parse s) | |
(error 'not-implemented "implement me!")) | |
; -------------- | |
; - Problem 3b - | |
; -------------- | |
(define (pretty-print-tree t) | |
(error 'not-implemented "implement me!")) | |
; -------------- | |
; - Problem 3c - | |
; -------------- | |
(define my-sexp-1 (error 'not-implemented "implement me!")) | |
(define my-sexp-2 (error 'not-implemented "implement me!")) | |
(define my-sexp-3 (error 'not-implemented "implement me!")) | |
(define my-tree-1 (error 'not-implemented "implement me!")) | |
(define my-tree-2 (error 'not-implemented "implement me!")) | |
(define my-tree-3 (error 'not-implemented "implement me!")) | |
#| Are there test cases you can come up with that violate the above two test criteria? Why or why | |
not? Briefly explain by referencing your code. | |
[Answer here...] | |
|# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment