Array.filter expects a predicate function, meaning one which returns a bool. Thus, is assumes the return of your function, x, must be a bool. Basically, what the error is saying is your array has one type of tuple, while your function expects a different type of tuple. I believe the function you want is Array.map.

By on 1/7/2010 3:12 PM ()
1
let sndArray = [| for (_,b,_) in arrayTuples do yield b |]
By on 1/8/2010 4:28 AM ()

Hello, Thank you marekb.
Your code works.
Thank you Paulmichael Blasucci for your explanation.
But I want you to explain marekb's code, so I can understand better.
Thanks,
Have a nice weekend.

By on 1/8/2010 10:59 AM ()

the code generates an array using a sequence expression.

See [link:msdn.microsoft.com] for a good explanation of sequence expressions.

By on 1/9/2010 7:00 AM ()

thankyou, marekb, for the cool sequence expression! I wouldn't have thought of that :)

My first impression was to use map, because, with some experience with F#, I've found that the Seq static functions usually do what i need..

1
2
let sndArray a =
    a |> Seq.map (fun (a,b,c) -> b)

I'm just completing the answer for zydjohn, not necessarily producing a better solution.

And, Zydjohn, I hope that you are enjoying the power of F# - neither of these solutions is "magic", but rather just using the language as it was intended.

Best wishes,

Javaman

By on 1/10/2010 6:55 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper