If you want a function that works on float[], then just add the type annotation.

If you want a function that works on any type 'a[], where 'a supports the given overloaded subtraction operator, then there are two choices:

  • pass in the "subtract" function as an argument, e.g. "let f (-) data1 data2 = ..."
  • use "let inline f data1 data2 = ...", which delays commitment as to which operator is used through the use of code duplication (a bit like C++ templates). This is not really recommended for widespread use in your code, partly because it is not possible to use the same trick on type definitions, but is very effective in corner cases.

Cheers,

Don

By on 11/11/2006 5: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