通常,当我需要构建一个从0到10的列表时,我只是这样做:[0..10].这给了我一个从0到10的整数列表.但这次我需要一个从0到10的浮点列表.有没有办法做到这一点?
let testFunc (x: float<metre>) =
x
let otherTestFunc =
[0.0 .. 10.0] // How do I make this return float<metre>
|> List.map (fun x -> testFunc x)
Run Code Online (Sandbox Code Playgroud)
我不久前向F#团队报告过这个问题,但是在使用Measures时需要手动指定步骤.
let testFunc (x: float<metre>) =
x
let otherTestFunc =
[0.0 <metre> .. 1.0<metre> .. 10.0 <metre>] // How do I make this return float<metre>
|> List.map (fun x -> testFunc x)
Run Code Online (Sandbox Code Playgroud)