I would probably do something like:

1
2
3
4
list1
|> Seq.collect (fun obj -> obj.dic1)
|> Seq.filter (fun (KeyValue(k, _)) -> extObj.dic1.ContainsKey(k))
|> Seq.sumBy (fun (KeyValue(_, v)) -> v * 10.0)

(|KeyValue|) is used when enumerating a dictionary. The error is due to enumerating the Keys collection and not the dictionary itself.

By on 10/13/2011 6:46 PM ()

That code looks really neat!
But I get an error: "This expression should have type 'unit' but has type 'float'"

I get this error a lot in my journey converting to F#, which is probably a result of me not fully grasping types yet having come from R/Matlab/Python ;)

By on 10/14/2011 8:36 AM ()

Nevermind, I just hadn't assigned the value to anything..

Thanks for the answer Daniel!

By on 10/14/2011 9:56 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