On Nov 18, 2007 10:10 AM, Ralph G Selfridge <[EMAIL PROTECTED]> wrote:
> Just what is the definition of 'right fold' and 'left fold'? There would
> seem to be several in this forum.

Right fold is basically u/@,&x y

In other words, it is reduce with an independently specified initial value.

However, note that in the general case, m can be a different type from the
rest of the list (but m typically would be of the same type as the result of
the dyad u).  If you want to mix types like this in J, you might instead use
>u/@,&(<x) <"_1 y

This general case version can be a bit slow, because J currently includes
no special code to support this case.  (No one has presented any really
convincing cases about why something this obscure should be made really
fast.)

Left fold works basically the same way, but evaluates from left to right
instead of from right to left.  In other words u~/@|.@,&x y

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to