我正在调用需要float[]外部函数,但我的数组是float<m>[] 。 我如何从阵列中剥离度量单位?
我需要类似下面的函数,但这不会编译。 我想避免任何迭代或重复的数组,因为float<m>和float值是相同的...
let demeasure (arr:float<m>[]): float[] = float[] (arr)I am calling external function requiring float[], but my array is float<m>[]. How could I strip the unit of measure from array?
I need something like the function below, but this does not compile. And I would like to avoid any iterating or duplicating of the array, as float<m> and float values are identical...
let demeasure (arr:float<m>[]): float[] = float[] (arr)最满意答案
我相信一个强制转换为obj ,然后动态转换为float[]会起作用,例如
(arr :> obj) :?> float[]因为没有运行时表示。
可能还会看到
F#度量单位 - '提升'值浮动<something>
如何一般性地删除F#度量单位
I believe that a cast to obj, followed by a dynamic cast to float[] would work, e.g.
(arr :> obj) :?> float[]because there is no runtime representation.
Possibly see also
F# Units of measure - 'lifting' values to float<something>
How to generically remove F# Units of measure
更多推荐
发布评论