Skip to content

Commit

Permalink
Merge pull request #168 from cmsc430/ziggy
Browse files Browse the repository at this point in the history
Ziggy
  • Loading branch information
dvanhorn authored Feb 12, 2024
2 parents 68dc141 + b6e5074 commit 1756d7f
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
pages: write
id-token: write
environment:
name: github-pages
name: www
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
Expand Down
28 changes: 15 additions & 13 deletions langs/intro/bt.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,36 @@
(require rackunit))

;; type Bt =
;; | `leaf
;; | `(node ,Integer ,Bt ,Bt)
;; | (leaf)
;; | (node Integer Bt Bt)
(struct leaf () #:prefab)
(struct node (v l r) #:prefab)

;; Bt -> Boolean
;; Is the binary tree empty?
(define (bt-empty? bt)
(match bt
['leaf #t]
[(cons 'node _) #f]))
[(leaf) #t]
[_ #f]))

(module+ test
(check-equal? (bt-empty? 'leaf) #t)
(check-equal? (bt-empty? '(node 3
(node 7 leaf leaf)
(node 9 leaf leaf)))
(check-equal? (bt-empty? (leaf)) #t)
(check-equal? (bt-empty? (node 3
(node 7 (leaf) (leaf))
(node 9 (leaf) (leaf))))
#f))

;; Bt -> Natural
;; Compute the height of a binary tree
(define (bt-height bt)
(match bt
[`leaf 0]
[`(node ,_ ,left ,right)
[(leaf) 0]
[(node _ left right)
(+ 1 (max (bt-height left)
(bt-height right)))]))

(module+ test
(check-equal? (bt-height 'leaf) 0)
(check-equal? (bt-height '(node 3 leaf leaf)) 1)
(check-equal? (bt-height '(node 2 leaf (node 1 leaf leaf)))
(check-equal? (bt-height (leaf)) 0)
(check-equal? (bt-height (node 3 (leaf) (leaf))) 1)
(check-equal? (bt-height (node 2 (leaf) (node 1 (leaf) (leaf))))
2))
2 changes: 1 addition & 1 deletion www/assignments.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@local-table-of-contents[#:style 'immediate-only]

@include-section{assignments/1.scrbl}
@;include-section{assignments/2.scrbl}
@include-section{assignments/2.scrbl}
@;include-section{assignments/3.scrbl}
@;include-section{assignments/4.scrbl}
@;include-section{assignments/5.scrbl}
Expand Down
6 changes: 3 additions & 3 deletions www/assignments/1.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ the name or signature of any function given to you. You may add any
additional functions that help you solve the overall problem you're
tackling.

@section[#:tag-prefix "a2-" #:style 'unnumbered]{Testing}
@section[#:tag-prefix "a1-" #:style 'unnumbered]{Testing}

You can test your code in several ways:

Expand All @@ -45,13 +45,13 @@ You can test your code in several ways:
Note: running @tt{racket <filename.rkt>} will @bold{not} test the
file; you need to use @tt{raco} or DrRacket.

@section[#:tag-prefix "a2-" #:style 'unnumbered]{Submitting}
@section[#:tag-prefix "a1-" #:style 'unnumbered]{Submitting}

Use the included Makefile to run @tt{make submit.zip} (or simply
@tt{make}) to generate an appropriate @tt{submit.zip} file for
submitting to Gradescope.

@section[#:tag-prefix "a2-" #:style 'unnumbered]{Grading}
@section[#:tag-prefix "a1-" #:style 'unnumbered]{Grading}

Your submission will be graded for correctness. Passing the unit
tests included in the file is necessary but @bold{not sufficient} to
Expand Down
48 changes: 24 additions & 24 deletions www/assignments/2.scrbl
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
#lang scribble/manual
@title[#:tag "Assignment 2" #:style 'unnumbered]{Assignment 2: Racket Primer}
@title[#:tag "Assignment 2" #:style 'unnumbered]{Assignment 2: a86 Primer}

@bold{Due: Wednesday, September 13, 11:59PM}
@bold{Due: Wednesday, February 14, 11:59PM}

The goal of this assignment is to gain practice programming in Racket.
The goal of this assignment is to gain practice programming in a86.

@bold{This is a collaborative assignment.} You may work with anyone
you'd like on this assignment, but each person must submit their
@tt{main.rkt} file on Gradescope.

You are given a @tt{main.rkt} file (on ELMS under "Files"), that
contains a number of sections. In each section there are several
function ``stubs,'' i.e. incomplete function definitions with type
signatures, descriptions, and a small set of tests. Each function has
a bogus (but type correct) body marked with a ``TODO'' comment. Your
job is to replace each of these expressions with a correct
implementation of the function.

The last section of problems deals with functions that operate over a
representation of expressions in a lambda-calculus-like language and
asks you to compute a few simple facts about the given expression.

Make sure you do not rename the file. Also make sure not to change
the name or signature of any function given to you. You may add any
@tt{submit.zip} file on Gradescope.

You are given a @tt{a86-basics.zip} file (on ELMS under "Files"), that
contains a README, a Makefile, and a number of Racket modules. In
each module there are several ``stubs,'' i.e. incomplete definitions
with type signatures, descriptions, and a small set of tests. Each
definition has a bogus (but type correct) body marked with a ``TODO''
comment. Your job is to replace each of these expressions with a
correct implementation of the a86 code.

Make sure you do not rename any files. Also make sure not to change
the name or signature of any definition given to you. You may add any
additional functions that help you solve the overall problem you're
tackling.

Expand All @@ -37,15 +33,19 @@ You can test your code in several ways:
This is actually a configurable preference, but it is on by
default.}

@item{Using the command line @tt{raco test main.rkt} from
the same directory as @tt{main.rkt}.}]
@item{Using the command line @tt{raco test <filename.rkt>} from
the same directory as your Racket code will test the module
in @tt{<filename.rkt>}. If you run @tt{raco test .}, it will
test all of the Racket files in the current directory.}]

Note that running @tt{racket main.rkt} from the command line will
@bold{not} run the tests.
Note: running @tt{racket <filename.rkt>} will @bold{not} test the
file; you need to use @tt{raco} or DrRacket.

@section[#:tag-prefix "a2-" #:style 'unnumbered]{Submitting}

Submit your filled-in @tt{main.rkt} file on Gradescope.
Use the included Makefile to run @tt{make submit.zip} (or simply
@tt{make}) to generate an appropriate @tt{submit.zip} file for
submitting to Gradescope.

@section[#:tag-prefix "a2-" #:style 'unnumbered]{Grading}

Expand Down
Loading

0 comments on commit 1756d7f

Please sign in to comment.