> (I remember seeing this posted to these forums before, but
> I do not remember who to give credit for it.) 

http://www.jsoftware.com/pipermail/programming/2007-April/006160.html


R.E. Boss



> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:programming-
> [EMAIL PROTECTED] Namens Raul Miller
> Verzonden: woensdag 26 december 2007 22:20
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] maximum sub-sequence
> 
> Here's another approach for finding the first maximum
> subsequence:
> mss=: (#~ [: ((i. >./) ({ = ]) +/\@(0&=)) [: (- <./\) +/\)&.(_1&,)
> 
>    mss 1 2 3 _50 4 5 6 _60 5 5 5 _50 3 5 7
> 4 5 6
> 
> The basic expression for finding local subsequence
> maxima is
>   (- <./\) +/\ data
> 
> (I remember seeing this posted to these forums before, but
> I do not remember who to give credit for it.)
> 
> The expression ((i. >./) ({ = ]) +/\@(0&=)) groups its
> argument in sequences delimited by zeros, finds the
> first instance of a global maximum and returns true
> for items within the group containing that maximum
> value.
> 
> And, #~ is being used in a hook, to pull out the
> numbers from the original argument corresponding
> to this group.
> 
> Finally, I am using this hook under (_1&,) which means
> that each group is guaranteed to begin with a negative
> number which will be discarded from the result.
> 
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to