http://thxbye.livejournal.com/ ([identity profile] thxbye.livejournal.com) wrote in [personal profile] avva 2013-05-13 05:09 am (UTC)

Мне понравился вопрос, предложенный в своё время Joel Spolsky (код на JavaScript):

Using the function

function accumulate(combiner, nullValue, l)
{
	if (l.length == 0)
		return nullValue;
	var first = l.shift();
	return combiner(first, accumulate(combiner, nullValue, l));
}

Implement sumOfSquares, which calculates the sum of squares of a list, for example

sumOfSquares([1,2,3,4,5])

should evaluate to 55.

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting