Say I have two sequences of numbers, A and B.
How can I create an object to describe the relationship between the two sequences?
For example:
A: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9...
B: 0, 2, 4, 6, 8, 10, 12, 14, 16, 18...
B = 2A
The relationship, f() is how we get from A to B.
But given two arbitrary sequences, how can I construct f?
Also, how can I return f to the calling method so that it can simply use it straight away with any number? -- Can you use delegate
as a return type?
I have one idea but maybe you could advise me on it: I could use a decorator pattern to build an object containing various operators and constants etc... Then just generate the code. This is very messy and I don't want to use this method.
I'm not asking how to find f, I can do that. I'm asking how to model f.
Sorry if all that is not clear, I don't know how else to explain it.