-1

Let's say I have the set:

$$ A = \{1,2,3,4\} $$

How would I express something like this:

A.map(function (number, index, set) {
    return number - set[set.length - index - 1]]
});

Which would result in:

$$ B = \{-3, -1, 1, 3\} $$

Downgoat
  • 167

1 Answers1

1

You might need an ordered set, $(a_0,a_1,\dots,a_{N-1})$. Then, I guess, your function would return for a given $i$,

$$ a_i - a_{N-1-i}. $$

Is that what you are looking for?

Bernhard
  • 1,134