- Notifications
You must be signed in to change notification settings - Fork1
A node.js interface to the SWI-Prolog library
License
jansegre/node-swipl
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A node.js interface to the SWI-Prolog library. A fork ofnode-prolog-swi.
For now, this addon supports the creation of rules and facts 'on the fly' and querying.
The SWI-Prolog library requires theSWI_HOME_DIR
environment variable to be set (Seehttp://www.swi-prolog.org/FAQ/FindResources.html). Thus an example call could be:
SWI_HOME_DIR=/usr/lib/swi-prolog node tests/a.js
MissingSWI_HOME_DIR
will result in
[FATAL ERROR: Could not find system resources]
Now builds with node-gyp (Thanks to Johny Jose):
$ node-gyp configure$ SWI_HOME_DIR=/usr/lib/swi-prolog node-gyp build
After building, try running:
$ SWI_HOME_DIR=/usr/lib/swi-prolog NODE_PATH=build/Release node tests/a.js
If you like it, use and/or fork it. Corrections and improvements are welcome.
Initialization
var swipl = require('swipl');swipl.initialise();
Create module
var m = swipl.module("mymod");
Facts and rules (shortcut form.call_predicate("assert", [ term ])
)
m.assert("likes(romeo, julia).");{}
Querying - Single solution
m.call_predicate("likes", ["romeo", "X"]);{ X: 'julia' }
Querying - Query
m.assert("likes(john, julia).");{}var q = m.open_query("likes", ["X", "julia"]);undefinedq.next_solution();{ X: 'romeo' }q.next_solution();{ X: 'john' }q.next_solution();falseq.close();true
Cleanup
swipl.cleanup();
Licensed under LGPL a copy is available onthe LICENSE.txt file.
About
A node.js interface to the SWI-Prolog library
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Languages
- C++51.9%
- JavaScript36.3%
- Prolog9.7%
- Python2.1%