I want to do parameter defaulting....

eg

I want to write something like blah x y = x + y

and blah x = blah x 0

ie...default y with 0 if it isnt supplied....

can I do this kind of thing?

Yes, you can do that provided you put the function as a (static) member of a class. Here is an example

type MyBlahStuff =

static member Blah (x,?y) =

x + (defaultArg y 0)

Ralf Herbrich (SniperEye)

By on 11/1/2007 9:47 AM ()

that seems a bit ugly.....

perhaps I should explain more what I want to do....

I want a recursive function that takes a list and processes it. But I only want that function to go for a certain depth. So I figure I pass the depth through.... but I dont want the caller of the function to have to seed the initial depth what I want for general function call is

let rec blah l d = .... blah tail d+1

let blah l = blah l 0

type thing

By on 11/1/2007 1:19 PM ()

How about:

let blah l =
let rec blah' l d = ...
blah' l 0;;

By on 11/1/2007 3:58 PM ()

better..... but still a bit ugly :)

By on 11/2/2007 12:16 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