小编spa*_*org的帖子

scala:如何将ArrayBuffer转换为Set?

我一直在寻找一些关于如何将ArrayBuffera 转换为a的时间Set,HashSet我想这是准确的.任何提示?

collections scala

4
推荐指数
1
解决办法
6239
查看次数

How to sum a Set[ValidatedNel[String, Double]]?

I have this:

Set[ValidatedNel[String, Double]] 
Run Code Online (Sandbox Code Playgroud)

and I would like to sum the Doubles in it to get:

ValidatedNel[String, Double]
Run Code Online (Sandbox Code Playgroud)

If some elements in the values are then I would like to have matching strings.

I played with Set.sum and Numeric to no avail...

Here is the test of what I would like to achieve:

  test("Summing ValidatedNel works") {
    val val1: ValidatedNel[String, Double] = Valid(1.0)
    val val2: ValidatedNel[String, Double] = Valid(2.0)
    val values: Set[ValidatedNel[String, Double]] = Set(val1, val2)

    val validatedNelNumeric: Numeric[ValidatedNel[String, …
Run Code Online (Sandbox Code Playgroud)

functional-programming scala scala-cats

3
推荐指数
1
解决办法
56
查看次数