(Edit: I mean 'differentiate' as in telling the difference between two things, not as in f'(x) )
I have n series of numbers, let's say two for example, with some "empty" spaces between the numbers, and I want to add them element-wise. The problem is, I need to differentiate between the numbers, which can include 0, and the empty spaces, so I cannot use 0 as a placeholder in the empty spaces.
For example, using 'E' as the empty space character (edit: oops forgot E was a built-in symbol, it can be something else), 'adding' the following two series (in reality, they'd be much longer and be more than two series being added):
{-2, E, E, 0, E, -1, E}
{-1, E, 0, E, E, 1, 5}
I want to get
{-3, E, 0, 0, E, 0, 5}
So basically, the rules are:
In the ith position of the series (1D Tables) being added:
If all the members are 'E', then put 'E' in the ith position of the result series
Otherwise, add the numbers like normal, ignoring the Es
So now that I've defined what I'm wanting to do, can anyone think of an elegant way to implement it? Only thing I can think of is by defining my own custom adding function, but it seems like there should be a more clever way to do it?
Thanks.
E
is the base of natural logarithms $\endgroup$Plus[]
? You can repurpose one of the undefined operators likeCirclePlus[]
with your addition rules... $\endgroup$