Pattern matching issues
Long time no see! As we all know, The guile module (ice-9 match) includes an implementation for a pattern matcher as specified by Andrew K. Wright. I've recently been reading a book by Peter Norvig, where he came up with the following notation for what he called "Segment Pattern Matching" (in Common Lisp): (pat-match '((?* ?p) need (?* ?x)) '(Mr Hulot and I need a vacation)) should return ((?P MR HULLOT AND I) (?X A VACATION)) I've been wondering if there is a way to represent this sort of pattern for the pattern matcher provided by Wright (and Guile). Regards, M.
Re: Pattern matching issues
Hello, Panicz Maciej Godek skribis: > (pat-match '((?* ?p) need (?* ?x)) '(Mr Hulot and I need a vacation)) > > should return ((?P MR HULLOT AND I) (?X A VACATION)) > > I've been wondering if there is a way to represent this sort of > pattern for the pattern matcher provided by Wright (and Guile). I don’t think so, unfortunately. That said, I recommend asking Alex Shinn since he’s the author of the implementation that comes with Guile 2.0 (now maintained as part of Chibi Scheme [0].) Thanks, Ludo’. [0] https://code.google.com/p/chibi-scheme/source/browse/lib/chibi/match/match.scm
Re: Pattern matching issues
Panicz Maciej Godek wrote: > I've been wondering if there is a way to represent this > sort of pattern for the pattern matcher provided by Wright > (and Guile). The syntax should be something like: (match '(Mr Hulot and I need a vacation) ((?x ... 'need ?y ...) (write (list ?x ?y)) (newline))) but at present multiple ellipses are not supported at the same level (that is in the same list or the same vector). It is possible to do it, but a policy (greedy/non-greedy) must be adopted to solve ambiguous cases and it gets complicated. HTH -- Marco Maggi