Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Bringing Logic Programming to Perl

by duelafn (Vicar)
on Jan 22, 2005 at 18:04 UTC ( #424257=note: print w/replies, xml ) Need Help??

in reply to Bringing Logic Programming to Perl

I got the most enlightenment about logic programming from reading the description of the monkey and the banana toy problem as described here.

Replies are listed 'Best First'.
Re^2: Bringing Logic Programming to Perl
by Ovid (Cardinal) on Jan 23, 2005 at 05:41 UTC

    Well, this works, but it does show some limitations in the code. I'm adding this to my examples/ directory. Thanks for the pointer.

    use strict; use warnings; use aliased 'AI::Prolog::Parser'; use aliased 'AI::Prolog::Term'; use aliased 'AI::Prolog::Engine'; my $database = Parser->consult(<<'END_PROLOG'); perform(grasp, state(middle, middle, onbox, hasnot), state(middle, middle, onbox, has)). perform(climb, state(MP, BP, onfloor, H), state(MP, BP, onbox, H)). perform(push(P1,P2), state(P1, P1, onfloor, H), state(P2, P2, onfloor, H)). perform(walk(P1,P2), state(P1, BP, onfloor, H), state(P2, BP, onfloor, H)). /* getfood(state(_,_,_,has)). */ /* I'll have to fix this soonish! */ getfood(state(Bogus1,Bogus2,Bogus3,has)). getfood(S1) :- perform(Act, S1, S2), nl, print(S1), print(Act), getfood(S2). END_PROLOG my $parser = Parser->new("getfood(state(atdoor,atwindow,onfloor,hasnot +))."); my $query = Term->new($parser); my $engine = Engine->new($query,$database); print $engine->run;


    New address of my CGI Course.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://424257]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-02-26 19:49 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (376 votes). Check out past polls.