Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Logic Programming in Perl 6

31 views
Skip to first unread message

Ovid

unread,
Feb 3, 2005, 5:39:29 PM2/3/05
to perl6-l...@perl.org
My apologies if this has been asked and answered. I seem to recall it
being discussed, but for the life of me I can't find a clear reference
to it.

What is logic programming in Perl 6 expected to look like? Larry
writes that he wants "logic programming to be one of the paradigms that
Perl supports"
(http://www.mail-archive.com/perl6-l...@perl.org/msg08990.html).

Will this be implemented via rules? I get hints of that reading
through the Exegeses, but a concrete example that illustrates something
I'm more familiar with would be nice. For example, let's say I want to
perform the classic "append" operation from Prolog whereby I append
list X and list Y to get list Z. (You can read more about this at
http://www.perlmonks.org/?node_id=424075)

append(X,Y,Z).

1. Given X and Y, we can infer Z.
2. Given Y and Z, we can infer X.
3. Given Z, we can infer all X and Y that could append to form Z.

I get all of that from one definition of append and I don't have to
tell the language how to find those results (if you know Prolog, hush.
There's some hand-waving going on here).

I'm trying to figure out how that works in Perl 6. The closest I can
come up with for third example is this:

my $append = rx:any/
(<alpha>*)
{ let $X := $1 }
(<alpha>*)
{ let $Y := $2 }
/
while 'abcd' =~ $append {
say "X is $0{X} and Y is $0{Y}";
}

But I know that's probably far from correct. It also has problems.
First, it only operates on strings. Second, I can't do all make all
three examples work from the one regular expression. Is there more
here that I am not seeing (I confess to not having paid close
attention.)

And feel free to correct my syntax.

Cheers,
Ovid

=====
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

0 new messages