#r "FSharp.PowerPack.dll"
let c = vector [ 5.0; 8.0 ];我犯了很多错误:
发布于 2017-07-22 15:19:38
#r命令用于.fsx文件,您位于.fs文件中。如果要创建一个具有fsx扩展名的新文件,那么上面的内容就可以了。但是,您需要一个通向FSharp.PowerPack.dll的路径,下面的代码可以在我的机器上运行
#r """C:\Users\josep\exercism\fsharp\hello-world\packages\FSPowerPack.Core.Community.2.0.0.0\lib\Net40\FSharp.PowerPack.dll"""
let c = vector [ 5.0; 8.0 ];但是由于您使用的是.fs,我认为解决您面临的问题的一个更简单的方法是删除#r行,只需转到nuget并安装包FsPowerPack.Community。
那么你的代码就能正常工作了。
发布于 2017-07-23 02:27:21
好吧,我喜欢我的回答,这对初学者来说很简单。-它使用的是ResizeArray -这是我的问题的一个例子:
let vector = ResizeArray<float>()
vector.Add(1.0)
vector.Add(2.0)
printfn "CONTENTS"
vector |> Seq.iter (fun x -> printfn "%f" x)
// add range
vector.AddRange([3.0;4.0;5.0])
printfn "CONTENTS"
vector |> Seq.iter (fun x -> printfn "%f" x)
// remove
vector.RemoveAt(2)
printfn "CONTENTS"
vector |> Seq.iter (fun x -> printfn "%f" x)
// insert
vector.Insert(0,42.)
printfn "CONTENTS"
vector |> Seq.iter (fun x -> printfn "%f" x)https://stackoverflow.com/questions/45255740
复制相似问题