From 1cd55d81319e6d372eea832f45d6244e0da94727 Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Sun, 23 Nov 2025 10:59:12 +0100 Subject: [PATCH] ADDED: foldl/6, addressing #2973 --- src/lib/lists.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/lists.pl b/src/lib/lists.pl index c9761249..00a38af3 100644 --- a/src/lib/lists.pl +++ b/src/lib/lists.pl @@ -2,7 +2,7 @@ List manipulation predicates */ -:- module(lists, [member/2, select/3, append/2, append/3, foldl/4, foldl/5, +:- module(lists, [member/2, select/3, append/2, append/3, foldl/4, foldl/5, foldl/6, memberchk/2, reverse/2, length/2, maplist/2, maplist/3, maplist/4, maplist/5, maplist/6, maplist/7, maplist/8, maplist/9, same_length/2, nth0/3, nth0/4, nth1/3, nth1/4, @@ -314,6 +314,16 @@ foldl(G_4, [X|Xs], [Y|Ys], A0, A) :- call(G_4, X, Y, A0, A1), foldl(G_4, Xs, Ys, A1, A). + +%% foldl(+Goal, ?Ls0, ?Ls1, ?Ls2, +A0, ?A). +% +% Like `foldl/4`, with 2 additional lists. + +foldl(_, [], [], [], A, A). +foldl(G_5, [X|Xs], [Y|Ys], [Z|Zs], A0, A) :- + call(G_5, X, Y, Z, A0, A1), + foldl(G_5, Xs, Ys, Zs, A1, A). + %% transpose(?Ls, ?Ts). % % If Ls is a list of lists, Ts contains the transposition -- 2.54.0