s***@public.gmane.org
2003-10-25 03:54:54 UTC
I would like to remark that 'left' and 'right' in the traditional
fold-left and fold-right do *not* refer to the order in which the
elements of a collection are fetched: from the left or from the
right. Rather, these labels refer to associativity. Let us consider an
ordered collection, e.g., a list of three elements (e1 e2 e3). Then
fold-left opl seed lst === (((seed `opl` e1) `opl` e2) `opl` e3)
fold-right opr seed lst === (e1 `opr` (e2 `opr` (e3 `opr` seed)))
<snip>fold-left and fold-right do *not* refer to the order in which the
elements of a collection are fetched: from the left or from the
right. Rather, these labels refer to associativity. Let us consider an
ordered collection, e.g., a list of three elements (e1 e2 e3). Then
fold-left opl seed lst === (((seed `opl` e1) `opl` e2) `opl` e3)
fold-right opr seed lst === (e1 `opr` (e2 `opr` (e3 `opr` seed)))
Ah. That is most enlightening as always. Bradd, I believe this means
you'll have to add
(define collection-fold collection-fold-left)
to your code. :)
Scott