;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib htdp-intermediate-lambda-reader.ss lang)((modname mt2-p5-starter) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #t)))
Copyright By Assignmentchef assignmentchef
(require spd/tags)
(require 2htdp/image)
exams/2021w1-mt2/mt2-p5)
???) ;fill in your CWL here (same CWL you put for 110 problem sets)
1) ;this is actually problem 5 DO NOT EDIT OR DELETE THIS LINE!
In this problem you will be working with a simplified version of the data
definition the autograder uses to represent the grading of a submission.
We are providing you with the data definition, you must design two functions
that operate on that data.
Score ListOfScore)
(define-struct header (txt subs))
(define-struct terminal (mark txt))
;; Score is one of:
;; (make-header String (listof Score))
;; (make-terminal Natural String)
;; interp.
;;An abitrary-arity tree of Score.There are header scores and
;;terminal scores.
;;A header provides a kind of section divider in a grading report;
;;it has no actual mark of its own. It just has the text of the
;;header message, and a list of Score underneath the header.
;;A terminal score has a mark in points and the text describing the
;;that mark.
(define S1 (make-terminal .05 tests))
(define P1 (make-header Problem 1
(list (make-terminal.10 signature)
(make-terminal.05 tests)
(make-terminal.10 template tag)
(make-terminal 0template not intact))))
(define P3A (make-header Domain Analysis
(list (make-terminal.10 constants)
(make-terminal.10 changing)
(make-terminal.10 options))))
(define P3B (make-header Changing information
(list (make-terminal.05 define-struct)
(make-terminal.10 type comment)
(make-terminal.10 interpretation)
(make-terminal 0examples))))
(define TOP
(make-header Overall
(make-header Problem 2
(list (make-terminal .05 rules)
(make-terminal .10 template)))
(make-header Problem 3
(list (make-header Part A (list P3A))
(make-header Part B (list P3B)))))))
Score ListOfScore encapsulated)
(define (fn-for-score s)
(local [(define (fn-for-score s)
(cond [(header? s)
( (header-txt s)
(fn-for-los (header-subs s)))]
[(terminal? s)
( (terminal-mark s)
(terminal-txt s))]))
(define (fn-for-los los)
(cond [(empty? los) ()]
( (fn-for-score (first los))
(fn-for-los (rest los)))]))]
(fn-for-score s)))
(define (fold-score c1 c2 c3 b1 s)
(local [(define (fn-for-score s)
(cond [(header? s)
(c1 (header-txt s)
(fn-for-los (header-subs s)))]
[(terminal? s)
(c2 (terminal-mark s)
(terminal-txt s))]))
(define (fn-for-los los)
(cond [(empty? los) b1]
(c3 (fn-for-score (first los))
(fn-for-los (rest los)))]))]
(fn-for-score s)))
Complete the design of the two functions below.NOTE THAT:
you must include all htdf recipe elements except stubs
for one function your @template must be use-abstract-fn
for the other function your must template using the encapsulated
templates above
you MUST use the most appropriate template strategy for each
if both functions use the same template approach the second
function will receive a mark of 0
;; PROBLEM 5A
;; A function that consumes a Score and produces the total of all
;; the marks in the score tree.For example:
;; (total-marks TOP) should produce .95
total-score)
;; PROBLEM 5B
;; A function that consumes a String and a Score, and searches the
;; score tree for a header score with the given text.
find-section)
CS: assignmentchef QQ: 1823890830 Email: [email protected]
Reviews
There are no reviews yet.