Re: [Jprogramming] Performance of fork vs train

2016-06-23 Thread R.E. Boss
> -Original Message- > From: Programming [mailto:programming-boun...@forums.jsoftware.com] > On Behalf Of Moon S > Sent: donderdag 23 juni 2016 18:58 > To: programming > Subject: Re: [Jprogramming] Performance of fork vs train > > Yes, definitely, every sequence

Re: [Jprogramming] Performance of fork vs train

2016-06-23 Thread Raul Miller
I had noticed that quip also. And, while you can't actually prove that with J (well... J might aid you, but you would have to do the thinking part yourself), you can easily do this: N=:F x:i.10 I. N e. *:<.%:N 0 1 24 24{N 4900 I'm not quite sure where <.@%: starts failing, but that

Re: [Jprogramming] Performance of fork vs train

2016-06-23 Thread Moon S
Yes, definitely, every sequence is in OEIS :) And this is there too: The sequence contains exactly one square greater than 1, namely 4900 (according to Gardner). - Jud McCranie , Mar 19 2001, Mar 22 2007 [This is a result from Watson. - Charles R Greathouse

Re: [Jprogramming] Performance of fork vs train

2016-06-23 Thread Raul Miller
I need to do a better job of proofreading my messages. In this case I should have said "that implementation uses floating point" or something like that. Sorry about that, -- Raul On Thu, Jun 23, 2016 at 12:23 PM, Raul Miller wrote: > On a tangential note, there are faster ways of doing this.

Re: [Jprogramming] Performance of fork vs train

2016-06-23 Thread Raul Miller
On a tangential note, there are faster ways of doing this. If you are not comfortable with the math, yourself, you might use oeis with some example values and find https://oeis.org/A000330 which suggests F=: 3 :'y*(1+y)*(1+2*y)%6' Is that an adequate solution? F i.10 0 1 5 14 30 55 91 140 204

Re: [Jprogramming] Performance of fork vs train

2016-06-23 Thread 'Pascal Jasmin' via Programming
i.100' 0.417068 (10) 6!:2 '(>.@:%) i.100' 0.0309382 - Original Message - From: Moon S To: programming Sent: Thursday, June 23, 2016 8:27 AM Subject: Re: [Jprogramming] Performance of fork vs train I see, thank you! (10) 6!:2 '(+)i.1000' 0.0286

Re: [Jprogramming] Performance of fork vs train

2016-06-23 Thread Moon S
I see, thank you! (10) 6!:2 '(+)i.1000' 0.0286243 (10) 6!:2 '(+&:+) i.1000' NB. process whole array 0.0273438 (10) 6!:2 '(+@:+) i.1000' 0.0290984 (10) 6!:2 '([:++) i.1000' 0.0281622 (10) 6!:2 '+ + i.1000' NB. even this is slower 0.039037 (10) 6!:2

Re: [Jprogramming] Performance of fork vs train

2016-06-22 Thread Ric Sherlock
This isn't to do with forks vs trains per se. It is about J working better on (big) chunks rather than small ones. Using & or @ rather than &: or @: causes the verb to the left to operate on chunks that are a size determined by the rank of the verb to the right. Using @: or &: causes the verb to th

[Jprogramming] Performance of fork vs train

2016-06-22 Thread Moon S
I was searching integer solutions (k,m) for 1^2 + 2^2 + ... + k^2 = m^2 and I found that one expression runs much faster than the other: (#~(0=1|[:%:+/@:([:*:1+i.))"0) 2+i. 24 (#~(0=1|[:%:+/@:(*:&>:&i.))"0) 2+i. 24 The first one is ~100 times faster, and moreover, the expression