[racket] empty in patterns

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Wed Sep 29 08:14:43 EDT 2010

Is it correct that one can write (cons a d) in a pattern, but not empty?  Thus,

(define (insert-many ns s)
  (match ns
    [(? empty?) s]
    [(cons a d) (insert a
                        (insert-many d s))]))

works but

(define (insert-many ns s)
  (match ns
    [empty s]
    [(cons a d) (insert a
                        (insert-many d s))]))

does not have the intended semantics.  This seems unfortunate given
that we've adopted HtDP-style lists, as opposed to traditional Scheme
lists, into Racket wholesale.

Shriram


Posted on the users mailing list.