本文介绍了从阵列测量的剥离装置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打电话外部函数需要浮动[] ,但我的数组是浮动< M> []
我怎么会从阵列剥离的度量单位?

我需要的东西像下面的功能,但是这并不编译。
而且我想,以避免阵列中的任何迭代或者复制,因为浮动< M> 浮动值是相同的...

 让demeasure(ARR:浮动< M> []):浮法[] =浮动[](ARR)


解决方案

我认为,强制转换为 OBJ ,随后动态转换为浮动[] 会的工作,如:

 (ARR:> OBJ):>浮动[]

因为没有运行时再presentation。

也可能看到

F#计量单位 - 提升值浮动<&东西GT;

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)
解决方案

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

这篇关于从阵列测量的剥离装置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 21:15