;(+/\1,2>:/\d) <@(<./\)/. d
10 7 5 5 5 1 1 8 2 2
Exactly what I was seeking for.
I like this forum because every answer is not just a solution for the
problem,
but a bunch of ideas and inspirations.
Thanks.
On Fri, 24 Mar 2006 00:48:28 +0300, Oleg Kobchenko <[EMAIL PROTECTED]>
wrote:
;(+/\1,2>:/\r) <@(<./\)/. r
10 7 5 5 5 1 1 8 2 2
--- Mikl Kurkov <[EMAIL PROTECTED]> wrote:
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
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
__________
http://www.newhost.ru - ÃîâÝëÙ ÔÞÜ ÔÛï ²ÐèÕÓÞ áÐÙâÐ!
--
Mikl
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm