从阵列剥离测量单位(Strip Unit of Measure from array)

系统教程 行业动态 更新时间:2024-06-14 17:02:18
从阵列剥离测量单位(Strip Unit of Measure from array)

我正在调用需要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

更多推荐

本文发布于:2023-04-21 18:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/fadbbd0d91cf516faac3938ee8444869.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阵列   测量   单位   Strip   Measure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!