S
Simon Woods
Hi
I'm trying to generate a simple evaluator-type app.
I want to generate a list of operators and say how each is to be evaluated.
So, e.g., I want to add to a list of operators
Operators.Add "+", evaluation function here
Now I think I should be able to use lambda expressions here, but I don't
think I've quite got my head around how they relate to delegates. (I
think I want to use a delegate because in due course I want to
generalise it further to have other evaluation mechanism e.g.
DateDiff/SQL etc)
So, trying to get a more simple case working, I have a delegate
Public Function MathFunction(of T) as Func(Of T,T)
(I assume that the Func(of T,T) is right as I expect 2 arguments)
In the Operator list, I think I want to have a method
Public Sub Add(Byval operator as String, Byval evaluator as MathFunction)
My problem comes when I try and add the lambda. I've got something like
Operators.Add "+", Function(x,y) x+y
But I'm getting an error saying "nested function does not have the same
signature as delegate".
I'm getting a bit lost and wonder if anyone could offer some help.
Thx
Simon
I'm trying to generate a simple evaluator-type app.
I want to generate a list of operators and say how each is to be evaluated.
So, e.g., I want to add to a list of operators
Operators.Add "+", evaluation function here
Now I think I should be able to use lambda expressions here, but I don't
think I've quite got my head around how they relate to delegates. (I
think I want to use a delegate because in due course I want to
generalise it further to have other evaluation mechanism e.g.
DateDiff/SQL etc)
So, trying to get a more simple case working, I have a delegate
Public Function MathFunction(of T) as Func(Of T,T)
(I assume that the Func(of T,T) is right as I expect 2 arguments)
In the Operator list, I think I want to have a method
Public Sub Add(Byval operator as String, Byval evaluator as MathFunction)
My problem comes when I try and add the lambda. I've got something like
Operators.Add "+", Function(x,y) x+y
But I'm getting an error saying "nested function does not have the same
signature as delegate".
I'm getting a bit lost and wonder if anyone could offer some help.
Thx
Simon