Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A node.js interface to the SWI-Prolog library

License

NotificationsYou must be signed in to change notification settings

jansegre/node-swipl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Basic usage

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();

License

Licensed under LGPL a copy is available onthe LICENSE.txt file.

About

A node.js interface to the SWI-Prolog library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++51.9%
  • JavaScript36.3%
  • Prolog9.7%
  • Python2.1%

[8]ページ先頭

©2009-2025 Movatter.jp