Releases: preston/ruby-prolog
Releases · preston/ruby-prolog
Prettier Predicates
A quick fix to the DSL to support predicates with zero arity without the need for brackets. Example:
db = RubyProlog.new do
tags['fire'].fact
tags['paper'].fact
# BEFORE:
# is_lit[] << tags['fire']
# AFTER:
is_lit << tags['fire']
end
# BEFORE:
# db.query{ is_lit[] } #=> [{}]
# AFTER:
db.query{ is_lit } #=> [{}]
What is false?
Added support for using false
in your predicates. Quick examples:
db = RubyProlog.new do
foo[:_] << [false]
foo['x'].fact
bar[:_] << [:CUT, false]
bar['x'].fact
baz[false].fact
end
db.query{ foo['x'] } #=> [{}]
db.query{ bar['x'] } #=> []
db.query{ baz[false] } #=> [{}]
Sanding off some rough edges and then some
- ruby-prolog now supports Prolog's underscore
_
as a symbol:_
, for all your any-matching needs. - Instances of ruby-prolog now support
.clone
. This is useful for defining a base set of facts to clone multiple times (e.g. for every HTTP request), add facts to it, and discard it afterwards. - Creating a new instance has a slightly nicer syntax.
- Fixed some to_prolog bugs.
New API and a few features
- Querying now returns an array of all variable solutions. You also now query outside the instance_eval. See this test for a good example.
- Added a new
not_
predicate, corresponding to Prolog's\+
- Added
.to_prolog
in case you want to copy/paste your RubyProlog definitions into another Prolog environment.