Surprisingly, making simple filters DSP style is surprisingly easy, the easiest way to do this is probably:
Output = (1-Cut)*Output + Cut*Input
Where Input is between -1 and 1 and Cut is between 0 and 1 (cutoff).
All that is actually happening here is that the output is equal to a portion of the old output signal and the new input signal. Plugging in a few values makes this easier to see.
Say your input is the array: 0 1 1 1 1
Putting this into the filter above will give us the output values for 5 runs through the filter
Initially:
Output = 0
Cut = 0.5
0.5*0 + 0.5*0 = 0
0.5*0 + 0.5*1 = 0.5
0.5*0.5 + 0.5*1 = 0.75
0.75*0.5 + 0.5*1 = 0.875
0.5*0.875 + 0.5*1 = 0.9375
As you can see, the filter has "slowed down" the rate of change of the values in the array instead of going from 0 directly to 1, it will never actually reach 1 but will get there eventually.
Large values of C will give no cutoff, where small values will give more cutoff.
Depending on what you're using to calculate this filter, you may see that using the above formula uses two double calculations, by doing simple algebraic rearranging, you can cut this down to just one double calculation:
Output = Output + Cut*(Input - Output)
The above gives a low pass filter. To get a High pass filter, you just do the input - the lowpass function
HPOut = Input - Output