In Java, I want to define a normalizing function that takes one number as input but whose behavior is defined by multiple parameters.
Essentially, the Java equivalent of this in Lisp:
(define (normalizeVal min max floor ceiling)
(lambda (x) (/ (* (- ceiling floor) (- x min)) (+ (- max min) floor))))
In pseudo-code, I'd like to:
function parsing(data, normalizeValFunc) {
for (datum in data):
normalizeValFunc(datum);
}
var input = userData;
var min, max, floor, ceiling = /* Calculate min, max, floor, and ceiling */
var output = parsing(input, normalizeValFunc(min, max, floor, ceiling));
Passing functions as parameters in Java can be tricky because functions are not first class objects in Java. (Maybe Java 8 Lambda expressions changes this?) Other questions address the issue of passing functions as parameters in Java, such as How to pass a function as a parameter in Java?, What's the nearest substitute for a function pointer in Java?, and Function Pointers in Java
However, none of these questions concern passing a function whose behavior is defined by parameters other than the function's input value. I don't know in advance what the min, max, floor, and ceiling parameters of the normalization function will be, but I only want the effective normalizing function to take one argument, the value to be normalized.