
Journal Com2Kid's Journal: Why functions as first class objects rocks. (C#) 5
Ok technically for the sake of type safety they are delegates, but the COOL part is that this:
z1 = z0 - ( f(z0) / f'(z0) )
math formula ends up looking like this:
newResult = previousResult - ( f(previousResult) / fprime(previousResult) );
code.
That is awesome in terms of sheer readability, compared to the insane amount of crud I'd have to go through to write that in Java.
What is this? (Score:1)
Re: (Score:1)
I need to divide the results of two functions f(x) and f`(x), in other words, find f(x)/f`(x). The user can select f(x) and f`(x) from 3 different choices.
(f(x) is chosen and f`(x) is automatically paired with it)
.NET what the return type and parameter types of a set of re
I have a function, solver, that takes in two other functions as its parameters. To do this in C#, I create a delegate type. A delegate just tells
Too bad... (Score:2)
Not trying to troll... (Score:2)
Re: (Score:1)
In Java, I could make an abstract base class called MathFunction that had a single unimplemented method in it. I could then derive three concrete classes from this base class, each with a different implementation of that function. Then declare my variables to be of the base class type, and assign the more proper specific subtype to that initial variable.
But that is a lot of work for one lonely little function.
MathFuncti