let parallelTest n = Color(Color.DeepPink, Triangles(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.
-
Based on your code and some of your comments, it looks like you're not fully in the groove of F# programming style. Can you post your code and describe what you actually trying to do?Juliet– Juliet2009年10月11日 19:34:55 +00:00Commented Oct 11, 2009 at 19:34
3 Answers 3
Compose your function with ignore to make it return unit:
Parallel.For(0, 10, parallelTest >> ignore)
2 Comments
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.
Comments
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?