I have a list of types IList<Effort>. The Force Model contains a float, called Amount. I would like to return the amount Amountfor the entire list in F #. How will this be achieved?
IList<Effort>
float
Amount
efforts |> Seq.sumBy (fun e -> e.Amount)
Simplified answers Seq.fold, pipelined Seq.foldand pipelined Seq.sumBy(I like the third option).
Seq.fold
Seq.sumBy
However, no one mentioned what the seq<'T>F # name is for IEnumerable<T>, so the module functions Seqwork on anyone IEnumerable, including ILists.
seq<'T>
IEnumerable<T>
Seq
IEnumerable
IList
Seq.fold (fun acc (effort: Effort) -> acc + effort.Amount) 0.0 efforts
, , , . sepp2k , effort effort, ( effort.Amount, " ). :
effort
effort.Amount
efforts |> Seq.fold (fun acc effort -> acc + effort.Amount) 0.0
effort, , efforts IList<Effort>. , , .
efforts
Source: https://habr.com/ru/post/1739698/More articles:How to fix these compiler errors? - c ++Trying to determine the best design for this workflow - C # - 3.0 - workflowNeed help setting up comet code - jqueryHow do I change the current directory from a python script? - pythonКак реализовать одноразовый шаблон в классе, который наследуется от другого одноразового класса? - design-patternsJsonResult shows file loading in browser - jqueryPassing javascript in a dynamic action handler - javascriptASP.NET Web Service Using Form Authentication from a Windows Application - asp.netLive issue with jQuery - jqueryasp.net url hiding? - asp.netAll Articles