Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pattern matching in Scheme

Name: Anonymous 2010-07-16 11:19

I’ve got this OCaml codebase I’d like to convert to Scheme, partly to learn the language, partly because I keep getting hit by OCaml’s weird syntax.

Anyway, the aforementioned code makes heavy use of pattern matching. I’ve searched the documentation of DrScheme (now Racket), and found the module that seems to be perfect for me; however, I can’t seem to be able to make even the most basic example work: the code


(require scheme/match)

(define-struct tree (val left right))

(match (make-tree 0 (make-tree 1 #f #f) #f)
      [(tree a (tree b  _ _) _) (list a b)])


gives the error match: syntax error in pattern in: (tree a (tree b _ _) _)

Any of you have experience with pattern matching in Scheme?

Name: OP 2010-07-16 11:36

>>3
Well, it sure sounds kinda unhelpful...

Care to list your version of DrScheme, and the language you are running this under?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List