What am I doing wrong in this F# code?
let parallelTest n = Color(Color.DeepPink, Triangl开发者_如何学Pythones(sphere n));;
Parallel.For(0,10,new Action(parallelTest));;
Error message : error FS0001: Type mismatch. Expecting a int -> unit but given a int -> scene. The type 'unit' does not match the type 'scene'
I'll glad if some body help me.
Compose your function with ignore
to make it return unit
:
Parallel.For(0, 10, parallelTest >> ignore)
If you want 10 results, perhaps you want
[| for i in 0..9 do
async { return parallelTest i } |]
|> Async.Parallel
|> Async.RunSynchronously
This will return an array of 10 scene results.
At which position does this error message occur? (I can't reproduce the error since I don't know the delcarations of some functions you use)
I guess the following: Parallel.For
expects a int -> unit
(Action<int>
in standard .NET), but parallelTest
has a different type (int -> scene
) which is therefore incompatible.
And what are you trying to achieve with the whole code?
精彩评论