Re: [Jprogramming] Curiosity about an error report evolution

2019-03-11 Thread Raul Miller
True... though I think that only works if you are in the 'base' locale? Thanks, -- Raul On Mon, Mar 11, 2019 at 2:55 PM Henry Rich wrote: > > You can also set or refer to public values via a locative, ideal__ > > Henry Rich > > On 3/11/2019 2:53 PM, Raul Miller wrote: > > Also, if you really w

Re: [Jprogramming] Curiosity about an error report evolution

2019-03-11 Thread Henry Rich
You can also set or refer to public values via a locative, ideal__ Henry Rich On 3/11/2019 2:53 PM, Raul Miller wrote: Also, if you really wanted to do the public assignment, you could do it like this: 3 :'ideal=:y' 1 0 0 (You would need to use analogous explicit definitions to access that

Re: [Jprogramming] Curiosity about an error report evolution

2019-03-11 Thread Raul Miller
Also, if you really wanted to do the public assignment, you could do it like this: 3 :'ideal=:y' 1 0 0 (You would need to use analogous explicit definitions to access that value, instead of your locally defined value.) FYI, -- Raul On Mon, Mar 11, 2019 at 2:24 PM Henry Rich wrote: > > I me

Re: [Jprogramming] Curiosity about an error report evolution

2019-03-11 Thread Henry Rich
I meant it's your error, not an error in J On 3/11/2019 2:19 PM, Brian Schott wrote: I am having a similar curious result that may be related: notice that in the script loaded first =. is used and then =: is used . I wonder if the problem is exacerbated by the change from a verb to a noun, also.

Re: [Jprogramming] Curiosity about an error report evolution

2019-03-11 Thread Henry Rich
No, this is unrelated and is an error.  A public assignment to a name that is already privately defined is a domain error. (for your protection, since the public value would be hidden by the private value) Henry Rich On 3/11/2019 2:19 PM, Brian Schott wrote: I am having a similar curious resu

Re: [Jprogramming] Curiosity about an error report evolution

2019-03-11 Thread Brian Schott
I am having a similar curious result that may be related: notice that in the script loaded first =. is used and then =: is used . I wonder if the problem is exacerbated by the change from a verb to a noun, also. loadd'~user/test.ijs' ideal =. 3{."1 = i. 4 ideal =: 1 0 0 |domain error:

Re: [Jprogramming] LCM performance

2019-03-11 Thread Raul Miller
Yeah, looks like I wasn't saving any significant time with that square root stunt on the logarithm calculation. Thanks, -- Raul On Mon, Mar 11, 2019 at 12:38 PM Don Guinn wrote: > > 6!:2 'n=:*/p^<.y^.~p=.p:i._1 p:y=.10x' > > 0.690272 > > 40{.":n > > 6952838362417071970003075865264183883398

Re: [Jprogramming] LCM performance

2019-03-11 Thread Don Guinn
6!:2 'n=:*/p^<.y^.~p=.p:i._1 p:y=.10x' 0.690272 40{.":n 6952838362417071970003075865264183883398 On Mon, Mar 11, 2019 at 10:07 AM 'Mike Day' via Programming < programm...@jsoftware.com> wrote: > As mentioned (indirectly) in my second attempt to comment, the _ q: > version failed (on my Win

Re: [Jprogramming] LCM performance

2019-03-11 Thread 'Mike Day' via Programming
As mentioned (indirectly) in my second attempt to comment, the _ q: version failed (on my Windows 10 laptop, with 16Gb memory!) for 10, while yours was ok. As, of course, you know, your approach avoids factoring by predicting the maximum prime powers. Cheers, Mike Please reply to mike_li

Re: [Jprogramming] LCM performance

2019-03-11 Thread Raul Miller
And, that said, after playing with this, lcmseq 10x seems to be significantly faster than >./&.(_&q:) 1+i. 10x (at least on this machine). FYI, -- Raul P.S. if you are reading this in a context where the rest of this thread is not available, the definition of lcmseq was: lcmseq=: 3 : 0

Re: [Jprogramming] LCM performance

2019-03-11 Thread Raul Miller
Wasn’t thinking clearly though because the _ q: representation is much nicer... Sorry about the noise... — Raul On Monday, March 11, 2019, Raul Miller wrote: > __ q: I meant.. > > Thanks, > > — > Raul > > On Monday, March 11, 2019, Raul Miller wrote: > >> That’s a good approach. >> >> The _ q

Re: [Jprogramming] LCM performance

2019-03-11 Thread Raul Miller
__ q: I meant.. Thanks, — Raul On Monday, March 11, 2019, Raul Miller wrote: > That’s a good approach. > > The _ q: representation is really nice for this task. > > Thanks, > > — > Raul > > On Monday, March 11, 2019, Eugene Nonko wrote: > >> Here's the solution I ended up using: >> >> _&q:^:_

Re: [Jprogramming] LCM performance

2019-03-11 Thread Raul Miller
That’s a good approach. The _ q: representation is really nice for this task. Thanks, — Raul On Monday, March 11, 2019, Eugene Nonko wrote: > Here's the solution I ended up using: > > _&q:^:_1 >./ _ q: >: i. 1x > > Just factorize to prime exponents representation, find maximums and conver

Re: [Jprogramming] LCM performance

2019-03-11 Thread 'Mike Day' via Programming
Sorry - I pressed "send" instead of "paste..." ! Second try... taking a while as my J session got clogged up with extended hangovers and I had to force a close. You can save a bit of time and space by deferring the conversion to extended type:    (_&q:^:_1 >./ _ q: >: i. 1x) -: _&q:^:_1 x:>.

Re: [Jprogramming] LCM performance

2019-03-11 Thread 'Mike Day' via Programming
You can save a bit of time and space by deferring the conversion to extended type: On 11/03/2019 07:51, Eugene Nonko wrote: Here's the solution I ended up using: _&q:^:_1 >./ _ q: >: i. 1x Just factorize to prime exponents representation, find maximums and convert back from prime exponen

Re: [Jprogramming] LCM performance

2019-03-11 Thread Eugene Nonko
Here's the solution I ended up using: _&q:^:_1 >./ _ q: >: i. 1x Just factorize to prime exponents representation, find maximums and convert back from prime exponent representation. On Sun, Mar 10, 2019 at 2:35 PM Raul Miller wrote: > J's extended precision integer implementation is part o

Re: [Jprogramming] LCM performance

2019-03-11 Thread Eugene Nonko
Haskell does not have any clever way to short-circuit evaluation of LCM for arbitrary precision Integer type. LCM is defined as follows: lcm _ 0 = 0 lcm 0 _ = 0 lcm x y = abs ((x `quot` (gcd x y)) * y) And GCD is implemented straightforwardly using Euclid algorithm: g