F# Units of measure - 'lifting' values to float<something>

微笑、不失礼 提交于 2019-11-28 12:42:09
Robert

It looks like units of measure can't be type parameters for the moment (no idea if this will change). So the shortest way to write this is:

data |> List.map float |> List.map ((*) 1.0<m>)

EDIT

See also now FloatWithMeasure here

http://msdn.microsoft.com/en-us/library/ee806527(VS.100).aspx

Is there any reason why you have to map twice? What's wrong with this:

data |> List.map (fun x -> (float x) * 1.0<m>)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!