There are built-in functions “max” and “min”.
Sent from my iPhone
There are built-in functions “max” and “min”.
Sent from my iPhone
This should also achieve what you want
q)a!(a>min a)-a5 | 0
6 | 0
7 | 0
12| 1
4 | -1
5 | 0
7 | 0
6 | 0
5 | 0
4 | -1
5 | 0
same idea, shorten the code a little bit:
q)a!next(-‘:)(<’:)a
5 | 0
6 | 0
7 | 0
12| 1
4 | -1
5 | 0
7 | 1
6 | 0
5 | 0
4 | -1
5 |?
Yeah, totally misread the original problem :)
What I gave would give you the absolute maxima/minima, but not the relative