use actual toplevel answers

This commit is contained in:
Markus Triska
2023-03-08 23:35:11 +01:00
parent 21acb9361a
commit 56bd596af3

View File

@@ -72,7 +72,7 @@ resource_error(Resource, Context) :-
% ?- length("abc", N).
% N = 3.
% ?- length(Xs, 3).
% Xs = [_A, _B, _C].
% Xs = [_A,_B,_C].
% ```
length(Xs0, N) :-
@@ -131,7 +131,8 @@ member(X, [_|Xs]) :- member(X, Xs).
%
% ```
% ?- select(c, "abcd", X).
% X = "abd".
% X = "abd"
% ; false.
% ```
select(X, [X|Xs], Xs).
select(X, [Y|Xs], [Y|Ys]) :- select(X, Xs, Ys).
@@ -142,7 +143,7 @@ select(X, [Y|Xs], [Y|Ys]) :- select(X, Xs, Ys).
%
% ```
% ?- append([[1, 2], [3]], Xs).
% Xs = [1, 2, 3].
% Xs = [1,2,3].
% ```
append([], []).
append([L0|Ls0], Ls) :-
@@ -155,7 +156,7 @@ append([L0|Ls0], Ls) :-
%
% ```
% ?- append([1,2,3], [4,5,6], Xs).
% Xs = [1, 2, 3, 4, 5, 6].
% Xs = [1,2,3,4,5,6].
% ```
append([], R, R).
append([X|L], R, [X|S]) :- append(L, R, S).