<?xml version="1.0" encoding="windows-1252"?>
<node id="186348" title="AI::Perlog -- Simple implementation" created="2002-07-30 16:15:22" updated="2005-08-10 17:08:58">
<type id="120">
perlmeditation</type>
<author id="17000">
Ovid</author>
<data>
<field name="doctext">
&lt;p&gt;There has been a bit of interest expressed in my &lt;tt&gt;[id://181980|AI::Perlog]&lt;/tt&gt; implementation, including requests for what code I have written so far.  While I do not intend to upload anything to the CPAN as I consider this code to be pre-alpha quality, I figured I may as well honor the request and let you [http://www.easystreet.com/~ovid/testing/AI-Perlog-.01.tar.gz|download the code].  The documentation is spotty, but the tests pass and the should give an indication of what's working and what's not.  Currently, the only thing I have implemented is boolean queries on facts.&lt;/p&gt;

&lt;code&gt;
use AI::Perlog;
my $pg = AI::Perlog-&gt;new;
$pg-&gt;add_fact( gives =&gt; qw/ Ovid money kudra / );
$pg-&gt;add_fact( gives =&gt; qw/ grep grief Ovid / );

# an underscore is synonymous with the empty string or undef
print "y\n" if $pg-&gt;gives( qw/ _ _ kudra / );       # does anyone give anything to kudra?
print "y\n" if $pg-&gt;gives( '', '', 'kudra' );       # same thing
print "y\n" if $pg-&gt;gives( undef, undef, 'kudra' ); # same thing
print "y\n" if $pg-&gt;gives( qw/ grep _ Ovid / );     # does grep give anything to Ovid?
print "n\n" if ! $pg-&gt;gives( qw/ Ovid _ grep / );   # Returns false. Ovid gives nothing to grep
&lt;/code&gt;

&lt;p&gt;Needless to say, it's just a toy right now, but I hope to have the first stab at unification done later this week, at which point this might actually have some limited utility.  Currently, the code generates a spurious warning under Cygwin, but runs clean on Windows 2000 and RH 7.2 (both running 5.6.1).&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;
&lt;a href="/index.pl?node=Ovid&amp;lastnode_id=1072"&gt;Ovid&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;  You can read about some of the future plans at [http://use.perl.org/~Ovid/journal/6729|use.perl].&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt;  Also be aware that this beast eats memory for breakfast.  If anyone can come up with a less memory intestive solution that doesn't sacrifice performance, that would be great.  Also, I intend to eventually port much of this to [kobe://Inline::C], so the simpler the data structures, the better.&lt;/p&gt;

&lt;p&gt;&lt;small&gt;Join the &lt;a href="http://setiathome.ssl.berkeley.edu/stats/team/team_86606.html"&gt;Perlmonks Setiathome Group&lt;/a&gt; or just click on the the link and check out our stats.&lt;/small&gt;&lt;/p&gt;</field>
</data>
</node>
