I’m trying to write a simple wrapper class in F# that takes a function that returns a string, and returns a function that takes the same parameters and returns the string from the input ‘wrapped’.
The following code works for functions that take a single variable (so test works fine):
open System
let myFunc anotherFunc =
fun x -> "boo" + anotherFunc x + "unboo"
let Func2 toDouble =
(toDouble * 2).ToString ()
let test = myFunc Func2
let Func3 numOne numTwo =
(numOne * numTwo).ToString ()
let test2 = myFunc Func3
do
Console.WriteLine(test 10)
Console.WriteLine(test2 5 10)
But because fun x -> specifies a single parameter, test2 is not valid code. Is there a piece of syntax that would allow for this construct?
Your function works.
The problem is in your last line when you do
should be
UPDATE:
I’m assuming you don’t want to change Func3. Otherwise the solution from Tomas could be what you need.