[plt-scheme] using plt-match.ss in teaching languages
If you change it to this:
(require (lib "plt-match.ss" "mzlib"))
(define-struct myposn (x y))
(define (dist p1 p2)
(match (list p1 p2)
[(list (struct myposn (x1 y1)) (struct myposn (x2 y2)))
(sqrt (+ (sqr (- x1 x2)) (sqr (- y1 y2))))]))
(dist (make-myposn 0 0) (make-myposn 3 4))
it works in all levels in my svn (version 3.99.0.23-svn1may2008
[3m].) I think you're seeing a bug in match that was recently fixed.
;; ---
I strongly discourage pattern matching in the first semester. Been
there, done that, failed with it. -- Matthias
On May 2, 2008, at 12:15 PM, Prabhakar Ragde wrote:
> The following program works in Advanced Student.
>
> (require (lib "plt-match.ss" "mzlib"))
>
> (define-struct myposn (x y))
>
> (define (dist p1 p2)
> (match `(,p1 ,p2)
> [(list (struct myposn (x1 y1)) (struct myposn (x2 y2)))
> (sqrt (+ (sqr (- x1 x2)) (sqr (- y1 y2))))]))
>
> (dist (make-myposn 0 0) (make-myposn 3 4))
>
> If I run it in Intermediate Student with lambda or below, I get the
> following error:
>
> map: all lists must have same size; arguments were: list (list
> #<syntax> #<syntax>) (list false)
>
> This is in 3.99.0.18-svn16mar2008.
>
> Is there a way to get match working in lower-level languages?
> Beginning Student with List Abbreviations would be ideal. Thanks. --PR
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme