From c3477d8476dde6341b279c6399cb7a798df04190 Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Wed, 8 Mar 2023 23:31:02 +0100 Subject: [PATCH 1/3] items --> elements This addresses #1740. --- src/lib/lists.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/lists.pl b/src/lib/lists.pl index 1bdaf61e..5eef37c2 100644 --- a/src/lib/lists.pl +++ b/src/lib/lists.pl @@ -63,7 +63,7 @@ resource_error(Resource, Context) :- %% length(?Xs, ?N). % -% Relates a list to its length (number of items). It can be used to count the elements of a current list or +% Relates a list to its length (number of elements). It can be used to count the elements of a current list or % to create a list full of free variables with N length. % % ``` From 21acb9361a624a190b3256b8d18759afedc358af Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Wed, 8 Mar 2023 23:32:05 +0100 Subject: [PATCH 2/3] use string notation as discussed on #scryer IRC --- src/lib/lists.pl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lib/lists.pl b/src/lib/lists.pl index 5eef37c2..a037fd85 100644 --- a/src/lib/lists.pl +++ b/src/lib/lists.pl @@ -67,14 +67,12 @@ resource_error(Resource, Context) :- % to create a list full of free variables with N length. % % ``` -% ?- length([a,b,c], 3). +% ?- length("abc", 3). % true. -% ?- length([a,b,c], N). +% ?- length("abc", N). % N = 3. % ?- length(Xs, 3). % Xs = [_A, _B, _C]. -% ?- length("chars", N). -% N = 5. % ``` length(Xs0, N) :- From 56bd596af3c33123e8dccf6d16075e92503d0005 Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Wed, 8 Mar 2023 23:35:11 +0100 Subject: [PATCH 3/3] use actual toplevel answers --- src/lib/lists.pl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/lists.pl b/src/lib/lists.pl index a037fd85..792c2be2 100644 --- a/src/lib/lists.pl +++ b/src/lib/lists.pl @@ -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).