|Keep It Simple, Stupid|
Test::More is only required for the tests. If you trust the code, you could go ahead and install it and hope it works.
How to find out everyone who owns gold, or who does not.. or is that what _check_path does?
That feature isn't implemented yet. It's what is called "unification", where data gets associated with a variable in a query. To find out who owns gold, a query like the following would probably be made:
Because Perlog would know that arguments beginning with a dollar sign are variables, it would know to grab the appropriate data and return it. I've been very busy this week or I would have put that in -- which is really the first thing that needs to go in to actually make this useful.
As a side note: I hate the proposed syntax above, so I am open for suggestions.
_check_path() is called from the following:
That loops over the arguments supplied in a query and says foreach argument, return false if I don't find a path to the next argument. The actual method call had a bunch of comments that I hadn't bothered to clean out since I wasn't planning on releasing this yet. You can ignore them. There was also a leftover line of debugging code that I forgot to clean out :) Here's the cleaned up method:
If you want to try and figure out that hideous data structure, you can read this brief explanation.
If you really, really are foolish enough to work on this, thank you :) Other than that, here's what you need to know about the object keys.
If it's not clear, a predicate can be thought of as the name of a rule.
In the above expample, "owns" and "gives" are the predicates.
FWIW I'd like to specify "*" as an alias to "_". Or would that mess up inside a qw()? Also I feel scared by the underscore since it seems like the mysterious used $_ without the $ and always wonder if something will get evaled when I wasn't watching. Though maybe intentional?
As for your comments about the underscore: that's borrowed from Prolog. If someone wants to make the query gives( qw/ grep grief _ / ); (which translates to "does grep give grief to anyone?"), then you cannot use the qw// syntax if only the empty string and undef are skipped. As for the asterisk suggestion, I like it, but for practical reasons, I can only use one character for that and I may as well use the standard one.
What else needed to solve the thief problem?
What has been your experience using a graph?
I was using a graph at first, but I realized that it was lacking some of the things that I needed so I rolled my own data structure. Right now, even though Graph.pm is listed as a prerequisite, I actually pulled it out of the module completely. I was mostly using it for tests. Pulling it out also had the nice side effect of doubling the speed of my code.
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.