F#类型不匹配问题在DirectX演示中
题
我一直想尝试 FDX演示 但是,由于兼容性问题,它给了我一系列错误和警告,因此我一直在尝试使其正常工作。完整的代码在一个 粘贴.
我在这里遇到的代码问题:
let drawSurf f (device:Device) =
let m,n = meshDims !mesh in
let data = Array.init (n*m) (fun k ->
let i,j = k2ij !mesh k in
let x,y = meshGet !mesh (i,j) in
let z = f (x,y) in // single precision f
(x,y,z))
in
let strips = triangleRows n m |> map (map (blendPlace !mesh data)) in
List.iter (fun strip -> drawTriangeStrip strip device) strips;
let m,n = meshDims !mesh in
let lines = gridLines n m in
let lines = lines |> map (colorPlace !mesh data Color.Black) in
drawLineList lines device
这给了我F#Interactive中的以下错误。
Motion-sample.fs(438,53):错误FS0001:键入不匹配。期待一个
(((('a *'b)列表 - >'c) *(('a *'b)列表 - >'d))ref
但是给了
(float [,] * float [,])参考。
类型'('a *'b)列表 - >'c'与类型“ float [,]''相匹配
谢谢你的帮助!
解决方案
我没有时间来看一下,但是尝试将网格定义更改为
let meshGet (mesh:_[,]*_[,]) (i,j) = let X,Y = mesh in X.[i,j], Y.[i,j]
编辑
实际上,更好的是,看起来有一个新鲜的副本
http://code.msdn.microsoft.com/fsharpsamples/release/projectRelealeases.aspx?releaseid = 2705
您应该使用它,而不是在Hubfs上发布的年历史。
不隶属于 StackOverflow