Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stepper internal error #178

Closed
samth opened this issue Oct 3, 2022 · 3 comments · Fixed by #181
Closed

stepper internal error #178

samth opened this issue Oct 3, 2022 · 3 comments · Fixed by #181
Assignees

Comments

@samth
Copy link
Sponsor Member

samth commented Oct 3, 2022

The program below causes an internal error in the stepper. I haven't been able to usefully minimize it yet. The error message is:

recon-source: no matching clause for syntax: (quote-syntax ((movie-title s) ... (movie-year s) ... (movie-minutes s) ...) #:local)

The test engine report lists blank errors as the error that occurred.

If I remove everything after the "exercise 4" comment then the stepper error goes away but the test engine behavior is still weird.

; A Show is one of:
; - (make-movie String Number Number)
; - (make-sitcom String Number Number)

(define-struct movie (title year minutes))
(define-struct sitcom (series season episode))

;Here are some examples of a Show:
(define show1 (make-movie "One Cut of the Dead" 2017 97))
(define show2 (make-sitcom "Rick and Morty" 2 6))
(define show3 (make-movie "Welt am Draht" 1973 205))
(define show4 (make-sitcom "Futurama" 4 15))


;exercise1


(define (process-show s) 
  (cond [(movie? s)
         (...(movie-title s)...
             (movie-year s)...
             (movie-minutes s)...)]
        [(sitcom? s)
         (...(sitcom-series s)...
             (sitcom-season s)...
             (sitcom-episode s)...)]))

 
;show-minutes: Show -> Number
;take a show and compute minute
;(define (show-minutes m)(...m..))

;exercise 2
(check-expect (show-minutes (make-sitcom "Rick and Morty" 2 6))20)
(check-expect (show-minutes (make-movie "One Cut of the Dead" 2017 97))97)


(define (show-minutes s)
  (cond [(movie? s)
         (movie-minutes s)] 
        [(sitcom? s)20]))
         
;exercise 3
;show-name: Show -> String
;take the name of the show and produce a string
;(define (show-name sn)(...sn...))

(check-expect (show-name(make-movie "One Cut of the Dead" 2017 97))
                        "One Cut of the Dead (2017)")
(check-expect (show-name (make-sitcom "Rick and Morty" 2 6)) 
              "Rick and Morty S2E6")


(define (show-name sn) 
  (cond [(movie? sn)
         (string-append (movie-title sn)" "
                        "("(number->string(movie-year sn))")")] 
        [(sitcom? sn)
         (string-append (sitcom-series sn)" ""S"
                        (number->string(sitcom-season sn))
                        "E"(number->string(sitcom-episode sn)))]))



;exercise 4
; A Job is one of:
; - (make-entry Number) 
; - (make-promotion Number Job)

(define-struct entry[initial-salary])
(define-struct promotion[raise old-job])


;exercise 5
(define firstJob(make-entry 100))
(define secondJob(make-promotion 200 (make-entry 100)))
(define thirdJob(make-promotion 200
                                (make-promotion 100 (make-entry 50))))



                                       
;exercise 6
(define (process-job j)
  (cond [(entry? j)(...(entry-initial-salary j)...)]
        [(promotion? j)
         (...(promotion-raise j)
             (process-job(promotion-old-job j)))]))

 
;exercise 7
;salary: job -> Number
;take in a job and produce the salary of that kind of job
;(define (salary s)(...s...))

(check-expect (salary firstJob) 100)
(check-expect (salary secondJob)300)
(check-expect (salary thirdJob) 350)

(define (salary j)
  (cond [(entry? j)(entry-initial-salary j)]
        [(promotion? j)
         (+ (promotion-raise j)(salary(promotion-old-job j)))]))

;exercise 8
;pay-cut?: job -> Boolean
; take a job and see if the job receive any negative raise.


(check-expect (pay-cut? (make-entry -100))false)
(check-expect (pay-cut? (make-promotion 200
                                       (make-entry 100)))false)
(check-expect (pay-cut? (make-promotion -100
                                       (make-entry 90)))true)
(check-expect (pay-cut? (make-promotion -100
                                        (make-entry -90)))true)
(check-expect (pay-cut? (make-promotion 100
                                        (make-entry -100)))false)


(define (pay-cut? j)
  (cond [(entry? j)false]
        [(promotion? j)
         (cond
           [(< (promotion-raise j) 0)true]
           [else (pay-cut?(promotion-old-job j))])]))



;exercise 9
;raise-amount is a number 
;promote: job number -> job
;take a job and a raise amount produce a new job

(check-expect (promote (make-entry 100) 100)
              (make-promotion 100
                              (make-entry 100)))

(check-expect (promote (make-promotion 100
                                       (make-entry 100))200)
              (make-promotion 200
                              (make-promotion 100 
                                              (make-entry 100))))

(check-expect (promote (make-promotion 200
                                       (make-promotion 100
                                                       (make-promotion 300
                                                                       (make-entry 100))))50)
              (make-promotion 50
                              (make-promotion 200
                                              (make-promotion 100
                                                              (make-promotion 300
                                                                              (make-entry 100))))))

(check-expect (promote (make-entry 100)0)
              (make-promotion 0
                              (make-entry 100)))


(define (promote j n)
  (cond [(entry? j)(make-promotion n (make-entry(entry-initial-salary j)))]
        [(promotion? j)
        (make-promotion n(promote(promotion-old-job j)(promotion-raise j)))]))     
@samth
Copy link
Sponsor Member Author

samth commented Oct 3, 2022

Error originally reported by one of @ccshan's students.

@sorawee
Copy link
Contributor

sorawee commented Oct 3, 2022

Related: #168

@ccshan
Copy link
Contributor

ccshan commented Oct 3, 2022

Error originally reported by one of @ccshan's students.

(namely Jack Huynh)

samth added a commit to samth/htdp that referenced this issue Oct 11, 2022
jbclements pushed a commit that referenced this issue Oct 18, 2022
Fixes #178. Related to #168.

(cherry picked from commit d2aa76a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants