ztangent / Julog.jl

A Julia package for Prolog-style logic programming.
Apache License 2.0
170 stars 11 forks source link

Update README with list built-in shorthand #3

Closed CrashBurnRepeat closed 4 years ago

CrashBurnRepeat commented 4 years ago

If I'm understanding https://github.com/ztangent/Julog.jl/blob/master/test/lists.jl correctly, the correct syntax for lists requires the list prefix, as something like [x,y,z] without it will be a Const array.

CrashBurnRepeat commented 4 years ago

@ztangent I'm realizing that this pull request is incomplete... I believe the list prefix is for pre-constructed Julog terms whereas lists can be declared without it within expressions.

So for instance, it's needed in this case:

member_def = @julog [
    member(X,[X | _])<<=true,
    member(X,[_ | Tail])<<=member(X,Tail)
]

tl = @julog list[ann, bob, carl]

goal=@julog member(ann, :tl)

resolve(goal, member_def)

but not in this one

goal=@julog member(ann, [ann, bob, carl])

resolve(goal, member_def)

This tripped me up a bit, so it may be a good addition to the README. Maybe even its own short section?

ztangent commented 4 years ago

Thanks for raising this issue! You're right about the list prefix -- I only added the functionality recently and didn't document it. I've updated the README in the Syntax section accordingly -- will merge and close this PR!