我正在尝试将字符串转换为浮点数并找到它们的总和:
> String.split "," "0.2,0.3,3.1"
> List.map String.toFloat ["0.2","0.3","3.1"]
> List.sum [Just 0.2,Just 0.3,Just 3.1]
Run Code Online (Sandbox Code Playgroud)
但我收到这些编译器消息:
This argument is a list of type:
List (Maybe Float)
But `sum` needs the 1st argument to be:
List number
Hint: Use Maybe.withDefault to handle possible errors. Longer term, it is
usually better to write out the full `case` though!
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到这些值的总和?