I’m learning F# and am struggling to parse the intellisense that appears for Seq.fold:
val fold : ('State -> 'T -> 'State) -> 'State -> seq<'T> -> 'State
In C# I’m accustomed to the Aggregate extension method and can understand perfectly fine the C# declaration:
(extension) TAccumulate Aggregate<TSource, TAccumulate>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func);
So in order to understand/deduce the F# syntax in this case, I’ve been trying to establish an analogy between Seq.fold and Aggregate but perhaps this is the wrong approach. I understand that -> defines a function (or the signature?), but beyond that I’m having a hard time reading what appeared.
To be clear, I don’t need an example of how to use folding; I’m simply looking for a breakdown of the the F# syntax used in the Seq.fold intellisense. Thanks.
In F# and many other functional languages,
'a -> 'b -> 'c -> 'dis the type of function which takes parameters of type'a,'b,'cas input*, and returns a'd. Someans, in C#, a function of type
and
means, in C#, a function of type
*: currying is ignored for the moment.