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
gives the error match: syntax error in pattern in: (tree a (tree b _ _) _)
Any of you have experience with pattern matching in Scheme?
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?