I need function that for each value in vector return this value if
previous was bigger and return closest minimum if previous data is lesser.
Examlpe:
d =: 10 7 5 6 7 1 9 8 2 4 NB. data
r =: 10 7 5 5 5 1 1 8 2 2 NB. result
NB. What I have now is
fn1 =: ({:@])`[ @. ( [ < [EMAIL PROTECTED])
fn2 =: [ , [EMAIL PROTECTED] , fn1
fn =: (}. @: (fn2/) @:(,{:)@: |.) f.
r -: fn d
1
But it realy slow and I think it could be optimized.
So what would you suggest?
Thanks in advance.
--
Mikl
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm