[<<][meta][>>][..]
Tue Feb 19 16:01:27 CET 2013

for/fold to accumulator assigments

Modified for/fold  (no generic input streams: explicit index sequence).

(let*/values
  ((a1 a2) (for/fold
               ((s1 0)
                (s2 1))
               ((i (in-range 0 n)))
             (values (+ (arr i) s1)
                     (* (arr i) s2)))))


Question is: how to make this easier in C?  The above is still an
expression language, while C is an assignment language..

So let's keep the above form, since it keeps us in the expression
domain, and it also makes C code simpler, since we can juse use

_ a1 = s1;
_ a2 = s2;


The modified for/fold form then can be

(fold-dim i n
  ((s1 0)
   (s2 1))
  <expr>)

However, that one is not a map/fold as the one we're abstracting, so
maybe stick to the current approach first, then move to an "abstract"
accumulator later (for/fold style).



[Reply][About]
[<<][meta][>>][..]