develooper Front page | perl.perl6.language | Postings from February 2005

Logic Programming in Perl 6

February 3, 2005 14:39
Logic Programming in Perl 6
Message ID:
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"

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


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/
    { let $X := $1 }
    { 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

And feel free to correct my syntax.


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 -- Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About