Question: ( define LOC 0 empty ) ( define - struct course ( number credits dependents ) ) ;;James, pls check below Course instances are correct,
define LOC empty
definestruct course number credits dependents
;;James, pls check below Course instances are correct, Course number is defined.
define Cmakecourse LOC
define Cmakecourse C
define Cmakecourse C
define Cmakecourse C
define Cmakecourse C C
define Cmakecourse C C
;define list of all course in natural numer
define listofcourse list
;define treelist in course numer
define treelist list C C C C C C
;; helper function to extract course numbers from a single course
define allcoursenumberscourse course
list coursenumber course
;; produce a list of all course numbers in the given tree
define allcoursenumbers tree
cond
empty tree empty
course treeallcoursenumberscourse tree
list treeallcoursenumbersloc tree
else error "Invalid input"
;; helper function to extract course numbers from a list of courses
define allcoursenumbersloc loc
apply append map allcoursenumbers loc
define courseswcredits c credits
;; Produce a list of courses and their dependents with credits specified credits
cond coursecredits c credits
cons c courseswcreditsloc coursedependents c credits
else
courseswcreditsloc coursedependents c credits
define courseswcreditsloc loc credits
;; Helper function to process a list of courses and their dependents with credits specified credits
cond empty loc empty
else
append courseswcredits first loc credits
courseswcreditsloc rest loc credits
This program snippet doesn't run well for problem and below
@problem
;;
;; Design a function that produces the list of all the course numbers in the
;; course's tree including the given course's number.
;;
;; Your @htdf tag and the rest of the design MUST have the definition for
;; the function that takes Course as an argument first. The function that
;; operates on a list must be second. Marks will only be rewarded for
;; solutions that order the design this way.
;;
@problem
;;
;; Design a function that takes two arguments: a Course and a Natural, in that
;; order. It produces the list of courses in the tree that are worth that
;; many credits or more.
;;
;; Your @htdf tag and the rest of the design MUST have the definition for
;; the function that takes Course as an argument first. The function that
;; operates on a list must be second. Marks will only be rewarded for
;; solutions that order the design this way.
;;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
