Prolog Higher-order reduce predicate
<p>We can define a higher-order <em>map</em> predicate as:</p>

<pre><code>map([], [], F).
map([A|As], [B|Bs], F) :-
   call(F, A, B),
   map(As, Bs, F).
</code></pre>

<p>Similarly, we can define <em>fold</em> (left) as:</p>

<pre><code>fold([], Acc, Acc, _F).
fold([A|As], B, Acc1, F) :-
   call(F, Acc1, A, Acc2),
   fold(As, B, Acc2, F).
</code></pre>

<p>What is the correct definition for <em>reduce</em> (left)? Can we define it as follows?</p>

<pre><code>reduce([A|As], Bs, F) :-   
   fold(As, Bs, A, F).
</code></pre>

<p>And <em>reduceback</em> (right) as follows?</p>

<pre><code>reduceback([], Ident, F) :-
   identity(F, Ident).
reduceback([A|As], B, F) :-
   reduceback(As, C, F),
   call(F, C, A, B).
</code></pre>

<p>Are these correct? </p>