Oh, well, you could make it tacit. For example:

   rg=:(((#/.~@])`(~.@])`(0*[)} +/?@##)+-) *

That does not speed it up, though.

Anyways, good luck,

-- 
Raul


On Thu, Jul 27, 2017 at 12:29 AM, Jimmy Gauvin <jimmy.gau...@gmail.com> wrote:
> I was hoping to get rid of some or all of the temporary vars so I guess
> I'll try option 2 and see if I can come up with something.
>
> I like the *y instead of y>0
> and the #/.~
> the }~ was a bit harder to grasp until I realized that } is an adverb
> and then the equivalence of "what where} array" and "array where}~ what"
> started making sense
>
> thanks
>
> and, yes, it does help
>
> On Wed, Jul 26, 2017 at 6:10 PM, Raul Miller <rauldmil...@gmail.com> wrote:
>
>> When going for speed, there's two basic approaches:
>>
>> (1) try minor variations on the theme - rearrange to see if you can
>> eliminate anything, or to incorporate any known special code,
>>
>> (2) rewrite from scratch and see if that's faster.
>>
>> Personally, I don't see any way to make that one any faster, though I
>> can rewrite it:
>>
>>   rg=: 3 : '(y-g)+(0*g) (~.r)}~ #/.~ r=. ?(#y)#~ +/g=.*y'
>>
>> I can, of course suggest alternate "from scratch" rewrites - but
>> that's just by referring to previous posts in this thread.
>>
>> I don't know if this helps,
>>
>> --
>> Raul
>>
>>
>> On Wed, Jul 26, 2017 at 4:44 PM, Jimmy Gauvin <jimmy.gau...@gmail.com>
>> wrote:
>> > Hi,
>> >
>> > this function seems reasonably fast but  I think it could be re-arranged
>> to
>> > be a bit more compact,
>> >
>> > Would anyone have some tips as how to go about this?
>> >
>> > rg =: 3 : '(y-g) + (r #/. r) (~. r =. ? (+/ g =. y>0)$ $y) } 0 $~ $y'
>> >
>> >
>> >    ts 'rg ^:10000 ] 400$100'
>> >
>> > 0.209447 38272
>> >
>> >
>> >    ts 'rg ^:100000 ] 400$100'
>> >
>> > 2.10048 38272
>> >
>> >
>> >
>> > Thanks
>> > ----------------------------------------------------------------------
>> > For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> ----------------------------------------------------------------------
> 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