You need the parens, lest it parse like

let AddFirstTwo ThreeVector (x,y,z) =

e.g. where AddFirstTwo takes two parameters, the first being named 'ThreeVector', and the second being a tuple. The parens change the interpretation to a single-argument that is a pattern. This is also true for binding values, a la

let (ThreeVector(x,y,z)) = expr

without the parens, you define a new function. See also 6.7.1.2

[link:research.microsoft.com]

You can't specify multiple alternatives in a function declaration; you must use 'match', or 'function' as in

1
2
3
4
5
6
7
8
#light

type Vector = 
    ThreeVector of int*int*int

let AddFirstTwo = function
    | ThreeVector(first,second,7) -> first+second
    | ThreeVector(first,second,third) -> 0

see also 6.6.4

[link:research.microsoft.com]

By on 12/6/2008 1:59 PM ()
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