Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Tuesday January 18, 2005
01:28 AM

It works

[ #22765 ]

There will be a lot of work before I can finally get this ready for the CPAN, but this works (and it's pure Perl):

#!/usr/local/bin/perl

use strict;
use warnings;
use lib './lib/';
use aliased 'AI::Logic::Parser';
use aliased 'AI::Logic::Term';
use aliased 'AI::Logic::Engine';

my $parser = Parser->new(thief_prog());
my $term   = Term->new($parser);

my $engine = Engine->new(
    $term,
    Parser->consult(
        thief_prog(),
        {},
    )
);
print $engine->run;
print $engine->more;

sub thief_prog {
    return <<'    END_PROG';
    steals(PERP, STUFF) :-
        thief(PERP),
        valuable(STUFF),
        owns(VICTIM,STUFF),
        not(knows(PERP,VICTIM)).
    thief(badguy).
    valuable(gold).
    valuable(rubies).
    owns(merlyn,gold).
    owns(ovid,rubies).
    knows(badguy,merlyn).
    END_PROG
}

My long-term plan is to make the Prolog part optional and simply allow writing normal Perl with an optional Prolog interface for those who want to play with the language.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.