scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

Add Example for element/3

Open jgarte opened this issue 2 months ago • 3 comments

https://www.scryer.pl/clpz.html#element/3

We should add a REPL example for element/3.

I can do this.

jgarte avatar Nov 07 '25 16:11 jgarte

:- use_module(clpz).

?- element(1, [0, 1, 2], 0).
%@    true.

?- element(1, [0, 1, 2], X).
%@    X = 0.

?- element(X, [0, 1, 2], 0).
%@    X = 1.

?- help(element/1).
%@    false.

jgarte avatar Nov 07 '25 16:11 jgarte

Please think about what a potential example should illustrate. Is there something in the documentation that can best be explained or illustrated by an example? Are there any remaining questions unless an example is added?

triska avatar Nov 07 '25 17:11 triska

Analogous to nth1/3.

I feel that this statement can be disambiguated. For example, How is element/3 comparable to nth1/3 exactly?

A code comparison example might be able to answer this question elegantly.

What do you think?

jgarte avatar Nov 08 '25 13:11 jgarte