I think it's to mirror the computation. E.g. from

[link:msdn.microsoft.com]

fold : ('State -> 'T -> 'State) -> 'State -> 'T list -> 'State

Applies a function to each element of the collection, threading an accumulator argument through the computation. This function takes the second argument, and applies the function to it and the first element of the list. Then, it passes this result into the function along with the second element, and so on. Finally, it returns the final result. If the input function is f and the elements are i0...iN, then this function computes f (... (f s i0) i1 ...) iN.

foldBack : ('T -> 'State -> 'State) -> 'T list -> 'State -> 'State

Applies a function to each element of the collection, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN then computes f i0 (...(f iN s)).

so that it mirrors the argument order. Also, I think these are the same signatures as in e.g. Haskell.

By on 11/18/2010 10:23 AM ()

Thanks for the explanation. I thought I'd let you know that the documentation for Array.foldBack is slightly confusing because it uses improper argument names.

(fun acc elem -> acc - elem)

should be

(fun elem acc -> elem - acc)

By on 11/18/2010 11:06 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper