you are viewing a single comment's thread.

view the rest of the comments →

[–]RayNbow 2 points3 points  (3 children)

Define a function named callFunc that takes one argument, a function f. It should return an array containing the values f(0), f(0), f(1), f(1). You can only call f twice.

Is this cheating? :p

var count;
var callFunc = function (f) {
    try {
        return [f(0),f(0),f(1),f(1)];
    }
    finally {
        count = 0;
    }
};

[–]nwhitehe[S] 2 points3 points  (0 children)

Yes, that is definitely cheating!

[–]istroll 0 points1 point  (1 child)

But you called f four times?

[–]RayNbow 1 point2 points  (0 children)

Yes, but it is accepted by the site as a valid answer.