Hi, the problem is that you are using snd as a class method, whereas fst and snd are functions defined in the F# library, so they are used as "snd someValue", not "someValue.snd"

This works...

1
if (snd arrIncrease.[1]) / (snd arrIncrease.[0]) >= 1.5 then printfn "Big increase!"

Or, a more general solution...

1
2
let IsBigIncrease (a : ('a*float) []) =
    ((snd a.[1]) / (snd a.[0])) >= 1.5

>> Thanks and Happy New Year to all!

Happy New Year to you! :)

By on 12/29/2009 3:43 PM ()

Hello, JavaMan:
Thank you very much for not only your code but also for your explanation. Now, I understand it better. As learning F# is not so easy.
Happy New Year to you!

By on 12/30/2009 12:21 PM ()

You're welcome, zydjohn. Yes, F# is not easy, and learning what's available as static functions, and what's available as member functions, is tricky. Visual Studio can be very helpful here. If you have VS, and the latest F# deployment, then intellisense is very good with prompting you.

You can seen on:

if arrIncrease.[1]. <--- see intellisense prompt member functions Equals, GetHasCode, etc..

But intellisense is not prompting snd, so it's probably not available. You can use Ctrl-space to force intellisense to prompt the available functions.

Unfortunately, intellisense didn't work so well with previous versions of F#, but I feel that it's working very well in the VS 2010 Beta 2, and F# 1.9.7.8.

We can track down the snd function also...

Enter the code I gave you into Visual Studio 2010, then put the mouse over snd, and you will see that's it's full name is Microsoft.FSharp.Core.Operators.Snd

On a new line, enter

Microsoft.FSharp.Core.Operators. <--- see intellisense prompt all the operators, including Snd

But Microsoft.FSharp.Core is opened by default, so you can also just use Operators.

Best wishes,

Javaman

By on 12/30/2009 3:54 PM ()

Hello, Javaman:
Thank you very much for your kind help and explanation.
Thanks and Happy New Year to you!

By on 1/1/2010 3:08 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