Closed cata closed 1 year ago
@cata Thanks, indeed Seq.sum
and some others probably just have a single implementation for the default +
operator. I have fixed the related issue #1283 first, as it's needed to process resolving generic operators, looking into this next.
@Jand42 - awesome, thank you!
These are the Seq
/List
/Array
functions that I would upgrade for better generic handling: sum
, sumBy
, average
, averageBy
.
Functions using comparisons (sorts) are already working well enough as the actual comparison is handled by a helper that checks for all cases. Similar idea could be implemented for required operations here. Possibly with fallback to a flat simple implementation with direct operator uses, for runtime performance.
@cata This is in GH build 6.0.5.244 right now.
Primitive numeral types still default to a function call that uses plain JS operators inside, but any other type compile to an inline that uses the type's defined get_Zero
and op_Addition
members. (And also DivideByInt
for average
)
Breaking change: you should now use sum
, sumBy
, average
, averageBy
functions with resolved generics, or annotate with [<Inline>]
@Jand42 - super, you guys are awesome!
Please see this Try WebSharper snippet for the repro.