[plt-scheme] Stepper doesn't run?

From: Joshua Zucker (Joshua_Zucker at castilleja.org)
Date: Thu Apr 22 15:11:55 EDT 2004

One of my introductory programming students has a program (below, in case
you're curious: the idea is to consume a list of (start end cost)
structures and find the cheapest possible route from place1 to place2)
which seems to break the stepper.

When I try to run the stepper, it says
"shared.ss": "annotate.ss" broke arglist-flatten's contract: (-> arglist?
(listof identifier?)): expected <arglist?>, given: #<syntax>

and, as a high school teacher with minimal previous programming
experience, I have no idea what that means!

She's running it in "intermediate student with lambda" language level and
no teachpacks.
The test cases she's created seem to paste funny into this email, but they
look normal in the program, and the stepper still gives an error even if I
choose "disable test cases", but it's a different error message:
unwind-define: expression is not a define-values: (list 'define-values
empty (list '#%app 'values))

I know at least one of the bugs in her program (that causes "rest" to get
passed a single structure rather than a list of one structure) ... but
that's a different issue.  I want HER to be able to track down that bug by
using the stepper!

Thanks for your help,
--Joshua Zucker

(define-struct planeticket (start end price))
(define alop1 (list (make-planeticket 'LA 'DC 800)
                    (make-planeticket 'Chicago 'DC 1000)
                    (make-planeticket 'SF 'DC 5000)))

; (define (check-list alop start end)
;   (filter (lambda (x) (and (symbol=? start (planeticket-price x))
;                            (symbol=? end (planeticket-end x))))
;           alop))


(define (cross list1 list2)
  (map (lambda (y) (map (lambda (x) (list y x)) list2)) list1))

(define (last list)
  (cond
    [(empty? (rest list)) (first list)]
    [else (last (rest list))]))

;;find one that matches start
(define (findmatch place alop)
  (filter (lambda (x) (symbol=? place (planeticket-start x))) alop))
.findmatch..(findmatch 'LA (list (make-planeticket 'LA 'DC 800)
                           (make-planeticket 'DC 'Chicago 1000)
                           (make-planeticket 'Chicago 'DC 5000))).(list
(make-planeticket 'LA 'DC 800)).

;;want to create a tree, start w/ trips possible starting from place want
to start
;;create all combos of ways to get to end
;;if at end, don't add to list
(define (tree alop end alocombos)
  (map (lambda (listoftrips) 
         (cond
           [(symbol=? end (planeticket-end (last listoftrips)))
(listoftrips)]
           [else ;(cheapest-price ;(kill-infinite 
            (cross alocombos (findmatch (planeticket-end (last
listoftrips)) alop))])) alocombos))
;;test
(tree alop1 'DC (list (make-planeticket 'LA 'DC 800)
                    (make-planeticket 'DC 'Chicago 1000)))
.tree..(tree alop1 'DC (list (make-planeticket 'LA 'DC 800)
                    (make-planeticket 'DC 'Chicago 1000))).(list
(make-planeticket 'LA 'DC 800)
                    (make-planeticket 'DC 'Chicago 1000)
                    (make-planeticket 'Chicago 'DC 1000)).




(define (calculate-price combotrips)
  (foldr (lambda (struct tot) (+ (planeticket-price struct) tot)) 0
combotrips))

.calculate-price..(calculate-price (list (make-planeticket 'LA 'DC 800)
                           (make-planeticket 'DC 'Chicago 1000)
                           (make-planeticket 'Chicago 'DC 5000))).6800.
; 
; (define (cheapest-price alocombos)
;   (map (lambda (combotrips) (calculate-price combotrips)) alocombos))


(define (kill-infinite alocombos)
  (filter (lambda (combotrips)
            (let ((endoftrip (planeticket-end (last combotrips))))
              (andmap (lambda (struct) (symbol=? (planeticket-start
struct) endoftrip)) combotrips)))
          alocombos))

.kill-infinite..(kill-infinite (list (list (make-planeticket 'LA 'DC 800)
                           (make-planeticket 'DC 'Chicago 1000)
                           (make-planeticket 'Chicago 'LA 5000))
                     (list (make-planeticket 'LA 'DC 800)
                           (make-planeticket 'DC 'Chicago 1000)
                           (make-planeticket 'Chicago 'DC 5000))
                     (list (make-planeticket 'LA 'DC 800)
                           (make-planeticket 'DC 'Chicago 1000)
                           (make-planeticket 'Chicago 'NY 5000)))).(list
(list (make-planeticket 'LA 'DC 800)
                    (make-planeticket 'DC 'Chicago 1000)
                    (make-planeticket 'Chicago 'NY 5000))).

;;master function, gets tree, checks cheapest, etc.
;(define (get-cheapest-way alop start end)
;)



Posted on the users mailing list.