* Pattern matching issues
@ 2011-07-12 21:05 Panicz Maciej Godek
2011-07-12 22:21 ` Ludovic Courtès
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Panicz Maciej Godek @ 2011-07-12 21:05 UTC (permalink / raw)
To: guile-user
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pattern matching issues
2011-07-12 21:05 Pattern matching issues Panicz Maciej Godek
@ 2011-07-12 22:21 ` Ludovic Courtès
2011-07-13 5:40 ` Marco Maggi
2011-07-23 18:44 ` Linas Vepstas
2 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2011-07-12 22:21 UTC (permalink / raw)
To: guile-user
Hello,
Panicz Maciej Godek <godek.maciek@gmail.com> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pattern matching issues
2011-07-12 21:05 Pattern matching issues Panicz Maciej Godek
2011-07-12 22:21 ` Ludovic Courtès
@ 2011-07-13 5:40 ` Marco Maggi
2011-07-13 10:42 ` Panicz Maciej Godek
2011-07-23 18:44 ` Linas Vepstas
2 siblings, 1 reply; 6+ messages in thread
From: Marco Maggi @ 2011-07-13 5:40 UTC (permalink / raw)
To: Panicz Maciej Godek; +Cc: guile-user
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pattern matching issues
2011-07-13 5:40 ` Marco Maggi
@ 2011-07-13 10:42 ` Panicz Maciej Godek
0 siblings, 0 replies; 6+ messages in thread
From: Panicz Maciej Godek @ 2011-07-13 10:42 UTC (permalink / raw)
To: Marco Maggi; +Cc: guile-user
2011/7/13 Marco Maggi <marco.maggi-ipsu@poste.it>:
> 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.
I agree that it could get complicated for the ambiguous cases,
but it should at least be possible for the simple ones. I think that
the lack of this capability is a serious limitation of a pattern
matcher. I'm not well acquainted with regular expressions, but
I could try to resolve this issue upon the book that I'm currently
reading -- provided that there's no one dealing with it at the
moment
Regards
M.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Pattern matching issues
2011-07-12 21:05 Pattern matching issues Panicz Maciej Godek
2011-07-12 22:21 ` Ludovic Courtès
2011-07-13 5:40 ` Marco Maggi
@ 2011-07-23 18:44 ` Linas Vepstas
2011-07-25 10:44 ` Andy Wingo
2 siblings, 1 reply; 6+ messages in thread
From: Linas Vepstas @ 2011-07-23 18:44 UTC (permalink / raw)
To: Panicz Maciej Godek; +Cc: guile-user
On 12 July 2011 16:05, Panicz Maciej Godek <godek.maciek@gmail.com> wrote:
> 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))
out of curiosity, do either the guile pattern matcher, or Norvig's,
operate on structures (lists of lists, etc) rather than just on strings?
Just asking out of curiosity; I maintain a pattern matcher for a
different project; it does pattern matching on arbitrary directed
graphs (equivalently, more or less, on terms in a term algebra).
Its used to implement queries against a database-like collection
of terms. (this is for the OpenCog project)
--linas
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-07-25 10:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-12 21:05 Pattern matching issues Panicz Maciej Godek
2011-07-12 22:21 ` Ludovic Courtès
2011-07-13 5:40 ` Marco Maggi
2011-07-13 10:42 ` Panicz Maciej Godek
2011-07-23 18:44 ` Linas Vepstas
2011-07-25 10:44 ` Andy Wingo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).