I think that an anonymous inner class will do exactly this.

I use this all the time to add random numbers to  matrix  (in Mahout-ish
dialect)

m.assign(new DoubleFunction() {
    double eval(double x) { return x + rand.nextGaussian(); }
})

Very handy.

On Thu, Aug 18, 2011 at 4:13 AM, Gilles Sadowski <
gil...@harfang.homelinux.org> wrote:

>
> However this is not what I need. The purpose is to have a shortcut for
> ---CUT---
> for (int i = 0; i < n; i++) {
>  final double value = <...>; // Not a constant.
>  v.setEntry(i, v.getEntry(i) + value);
> }
> ---CUT---
>

Reply via email to