Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writeq/1 incorrect writing of list #2356

Closed
UWN opened this issue Mar 12, 2024 · 2 comments
Closed

writeq/1 incorrect writing of list #2356

UWN opened this issue Mar 12, 2024 · 2 comments

Comments

@UWN
Copy link

UWN commented Mar 12, 2024

?- append(Xs, Ys, [a,b|Xs]), Ys = [b,a], writeq(Ys), nl.
   outputs("[b]\n"), unexpected,
   Xs = "a", Ys = "ba"
;  ... .
@UWN
Copy link
Author

UWN commented Mar 12, 2024

Shorter:

r(Ys) :-
   [a,b|Xs] = [X|Ys],
   Xs = [X].


?- r(Ys), writeq(Ys), nl.
[b]
   Ys = "ba".

@UWN
Copy link
Author

UWN commented Mar 12, 2024

r(Ys) :-
   [a,b|Xs] = [_|Ys],
   Xs = [e].

?- r(Ys), writeq(Ys), nl.
[b]   % unexpected
   Ys = "be".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant