3 ms·
Most concretely I mean it in the context of the common auxiliary-predicate-with-an-accumulator pattern: foo_bar(Foo, Bar) :- foo_bar_aux(Foo, Bar,
by tom_mellior 8y ago
Most concretely I mean it in the context of the common auxiliary-predicate-with-an-accumulator pattern:
foo_bar(Foo, Bar) :-
foo_bar_aux(Foo, Bar, 0).
foo_bar_aux(Foo, Bar, N) :-
...
Which in a language like OCaml would be hiding the loop in a recursive function defined inside the main one:
let foo_bar foo =
let rec foo_bar_aux n =
...
in
foo_bar_aux 0
So yes, I think this is what you mean by being the same predicate rather than a "change of scopes".
Of course there are many loop-like things that you can nest. If the arguments align just right, you can also use `maplist(maplist(maplist(baz)), ...)` instead of three auxiliary predicates, but I don't encounter many cases where this is possible or desirable.
- YeGoblynQueenne 8y agoI see what you mean, thanks. I think we're talking about the same thing then.