| Did you know ... | Search Documentation: |
| Pack starlog -- FOLDR_QUICK_REF.md |
foldr(Operation, List, Accumulator, Result)
Result is foldr(Operation, List, Accumulator)
% Prolog
?- string_chars("abc", C), reverse(C, R), foldr(string_concat, R, "", Result).
Result = "cba".
% Starlog
?- starlog_call(R is foldr(string_concat, reverse(string_chars("abc")), "")).
R = "cba".
% Prolog ?- foldr(append, [[1], [2], [3]], [], Result). Result = [1, 2, 3]. % Starlog ?- starlog_call(R is foldr(append, [[1], [2], [3]], [])). R = [1, 2, 3].
?- foldr(string_concat, [h, e, l, l, o], "", Result). Result = "hello".
foldr(f, [x1, x2, x3], acc) computes: f(x1, f(x2, f(x3, acc)))
Processing order: right to left (processes x3 first, then x2, then x1)