s-webber / projog

Prolog programming for the Java platform.
Apache License 2.0
37 stars 9 forks source link

Question / Feature Request: variable attributes, dif/2, dif/1, tfilter/3 etc #218

Closed sgparry closed 1 year ago

sgparry commented 1 year ago

Projog is a fantastic project - a modern native implementation of projog that integrates fully into Java via Maven - just what I was looking for. I am trying to port some scryer prolog code that uses dif/1, dif/2 and tfllter/3. Other prologs have these predicates as part of their CLP; in scryer, they are implemented using variable attributes. Some online references I have seen suggest co-routines are involved.

Can the equivalent be done in Projog 0.8.0 or would they require new features?

Having attributes would seem like a good feature to have in Projog and would get us a long way to implementing dif/2 etc.; I am not great at Prolog, but I know my Java and would be willing to have a go at coding a pull request with some guidance.

s-webber commented 1 year ago

Thank you for asking these questions. I'm always interested in getting feedback.

I will do some reading about variable attributes, dif/1, dif/2 and tfilter/3. When I have a better understanding then I will update this issue with more details.

s-webber commented 1 year ago

Hello @sgparry ,

I've made an attempt at supporting dif/2 and tfilter/3 in projog.

I've added an example to: https://github.com/s-webber/projog-examples/tree/master/tfilter It uses a version of projog-core that I've built from a branch named issue-218-variable-attributes.

The title of this issue mentions dif/1 but I've been unable to find any information about how this predicate should work. If you provide a link to some documentation, or an example that uses it, then I will take a look.

If this functionality works as you'd expect then I will tidy-up and unit-test the issue-218-variable-attributes changes before including them in the next release.

If you have any questions or comments then please let me know.

Thanks.

sgparry commented 1 year ago

Thanks, that's great. I will try it in the next couple of days and I will see if I can dig out the info on dif/1. All I could find before was where the scryer source code mentions it, and a use in the code I have.

On 12 March 2023 12:42:33 GMT, s-webber @.***> wrote:

Hello @sgparry ,

I've made an attempt at supporting dif/2 and tfilter/3 in projog.

I've added an example to: https://github.com/s-webber/projog-examples/tree/master/tfilter It uses a version of projog-core that I've built from a branch named issue-218-variable-attributes.

The title of this issue mentions dif/1 but I've been unable to find any information about how this predicate should work. If you provide a link to some documentation, or an example that uses it, then I will take a look.

If this functionality works as you'd expect then I will tidy-up and unit-test the issue-218-variable-attributes changes before including them in the next release.

If you have any questions or comments then please let me know.

Thanks.

-- Reply to this email directly or view it on GitHub: https://github.com/s-webber/projog/issues/218#issuecomment-1465187369 You are receiving this because you were mentioned.

Message ID: @.***> -- Sent from my Android device with K-9 Mail. Please excuse my brevity.

s-webber commented 1 year ago

Hello @sgparry ,

The latest version of projog-core is 0.9.0. This version includes support for dif/2.

For an example of how this can be used to support the use of tfilter/3 then please see:

https://github.com/s-webber/projog-examples/blob/master/tfilter/src/main/java/com/example/TfilterExample.java

Thanks again for raising this issue. If this change does not provide what you hoped for, or if you have any other questions or requests, then please raise a new issue.

Thank you.

sgparry commented 1 year ago

Thanks for the good work on this, I will try this out and let you know how it goes.

On 1 April 2023 15:34:00 BST, s-webber @.***> wrote:

Hello @sgparry ,

The latest version of projog-core is 0.9.0. This version includes support for dif/2.

For an example of how this can be used to support the use of tfilter/3 then please see:

https://github.com/s-webber/projog-examples/blob/master/tfilter/src/main/java/com/example/TfilterExample.java

Thanks again for raising this issue. If this change does not provide what you hoped for, or if you have any other questions or requests, then please raise a new issue.

Thank you.

-- Reply to this email directly or view it on GitHub: https://github.com/s-webber/projog/issues/218#issuecomment-1492987900 You are receiving this because you were mentioned.

Message ID: @.***> -- Sent from my Android device with K-9 Mail. Please excuse my brevity.