Re: [Jprogramming] Quora Challenge

2017-09-18 Thread Raul Miller
Or, you could do something like this: paren=:3 :0 y=.":y if.1<#;:y do. y=.'(',y,')' end. ;:y ) quoted=: 1 :0 : ;:inv(paren x),(paren m),;:": y ) 'g' quoted/19 29 59 79 89 109 119 139 149 179 199 19 g 29 g 59 g 79 g 89 g 109 g 119 g 139 g 149 g 179 g 199 Now you have a line you can

Re: [Jprogramming] Quora Challenge

2017-09-18 Thread Jimmy Gauvin
To answer "​There's got to be an easier way to list the interim values of insert" g/\.19 29 59 79 89 109 119 139 149 179 199 4 5 6 12 12 7 4 2 6 1 199 To see what \. does we can use < <\.i.5 ┌─┬───┬─┬───┬─┐ │0 1 2 3 4│1 2 3 4│2 3 4│3 4│4│ └─┴───┴─┴───┴─┘ \

Re: [Jprogramming] Rank (") with cyclic gerund

2017-09-18 Thread jose . mario . quintana
Right , either way I am fine and ready for a cyclical rank :) Sent from my iPhone > On Sep 18, 2017, at 7:53 PM, 'Pascal Jasmin' via Programming > wrote: > > m"_ if m is a gerund to be applied cyclically only makes sense if the rank is > less than _? > > > > >

Re: [Jprogramming] Rank (") with cyclic gerund

2017-09-18 Thread 'Pascal Jasmin' via Programming
m"_ if m is a gerund to be applied cyclically only makes sense if the rank is less than _? From: Jose Mario Quintana To: Programming forum Sent: Monday, September 18, 2017 7:39 PM Subject:

Re: [Jprogramming] converting inches to feet, inches (and 16ths of inches)

2017-09-18 Thread Raul Miller
0 12 10 #: 10 * y Or just 0 12 #: y, since the result gets displayed as a decimal... Thanks, -- Raul On Mon, Sep 18, 2017 at 5:17 PM, Skip Cave wrote: > How do you get feet, inches, and tenths of inches? > > Skip Cave > Cave Consulting LLC > > On Mon, Sep 18, 2017 at

Re: [Jprogramming] Rank (") with cyclic gerund

2017-09-18 Thread Raul Miller
Why not add the cyclic gerund functionality to u`:n? We've got a plethora of unassigned values for n, and this would not introduce any new inconsistency that could break existing code. Thanks, -- Raul On Mon, Sep 18, 2017 at 7:39 PM, Jose Mario Quintana wrote:

[Jprogramming] Rank (") with cyclic gerund

2017-09-18 Thread Jose Mario Quintana
On further consideration and or what is worth, I second your proposal. I would like to suggest to go even further and make no exceptions even for the case when n is _ . Why? First, because I do not like inconsistencies and the main point of changing " is to make consistent with other

Re: [Jprogramming] converting inches to feet, inches (and 16ths of inches)

2017-09-18 Thread Brian Schott
In your reply, you quoted Bo's answer which seems to me to provide the answer to your question. On Mon, Sep 18, 2017 at 5:17 PM, Skip Cave wrote: > How do you get feet, inches, and tenths of inches? > > Skip Cave > Cave Consulting LLC > > On Mon, Sep 18, 2017 at 2:31

Re: [Jprogramming] converting inches to feet, inches (and 16ths of inches)

2017-09-18 Thread Skip Cave
How do you get feet, inches, and tenths of inches? Skip Cave Cave Consulting LLC On Mon, Sep 18, 2017 at 2:31 PM, 'Bo Jacoby' via Programming < programm...@jsoftware.com> wrote: > 100 12#:166.7 NB. feet and inches > 13 10.7 > 100 12 16#:16*166.7 NB. feet and inces and sixteenth inches > 13 10

Re: [Jprogramming] Quora Challenge

2017-09-18 Thread Skip Cave
So does Roger's function work on the larger list? Let's see: (4 : '13|x*y') / 10 # 19 29 59 79 89 109 119 139 149 179 199 9 That looks like it does. Let's check with extended precision: (4 : '13|x*y') / 10 # 19 29 59 79 89 109 119 139 149 179 199x 9 So Roger's approach works without

Re: [Jprogramming] idiomatic way for x u"_ 1"1 _ y

2017-09-18 Thread Rudolf Sykora
On 18/09/2017, Raul Miller wrote: > Well, first, I'd ask why you would want to do that. Well, it just somehow quite naturally appeared in my code... (which, of course, could be reordered to avoid the construct) > But I'd go with something like x u"1~/~ y > (And note that

Re: [Jprogramming] Quora Challenge

2017-09-18 Thread Skip Cave
Roger said: But if the list were longer: 13 | */ 13 | 10 # 19 29 59 79 89 109 119 139 149 179 199 0 Wow! Yes I see the problem. It would be really nice if J would output a warning when a calculation exceeds the precision limits. I'm sure this would probably slow down all computations, so

Re: [Jprogramming] idiomatic way for x u"_ 1"1 _ y

2017-09-18 Thread Raul Miller
Yes... Well, first, I'd ask why you would want to do that. But I'd go with something like x u"1~/~ y (And note that y u~"1/ x is something like x u"1~/~ y ...). Thanks, -- Raul On Mon, Sep 18, 2017 at 3:35 PM, Rudolf Sykora wrote: > On 18/09/2017, Raul Miller

Re: [Jprogramming] idiomatic way for x u"_ 1"1 _ y

2017-09-18 Thread Rudolf Sykora
On 18/09/2017, Raul Miller wrote: > I'd use x u"1/ y nice, thanks. What about if it were the other way round, i.e. u"1 _"_ 1 ? Following what I learnt from you, I now know I can shorten to u"1"_ 1 . (One could also perhaps use some modification of u"1/~ ...) Thanks

Re: [Jprogramming] converting inches to feet, inches (and 16ths of inches)

2017-09-18 Thread 'Bo Jacoby' via Programming
100 12#:166.7 NB. feet and inches 13 10.7 100 12 16#:16*166.7 NB. feet and inces and sixteenth inches 13 10 11.2 Den 19:10 mandag den 18. september 2017 skrev Brian Schott : My car is 166.7 inches long according to the specs. Car cover coverages are measured in

Re: [Jprogramming] Quora Challenge

2017-09-18 Thread Roger Hui
Your solution works only because the list isn't too long, and the initial 13| (same as 13 |/) made them all small enough that you can do the */ without losing precision. But if the list were longer: 13 | */ 13 | 10 # 19 29 59 79 89 109 119 139 149 179 199 0 If it makes it more

Re: [Jprogramming] Quora Challenge

2017-09-18 Thread Skip Cave
Yes, one of the Quora answer posts for this challenge pointed this out as well, so I tried that approach. Not being too competent with the use of & @, I tried: 13|*/13|/19 29 59 79 89 109 119 139 149 179 199 4 I got the answer, but I need a course on the use of @ and & in order to tighten

Re: [Jprogramming] Puzzling result

2017-09-18 Thread Don Guinn
I had two dates for my checking. One when I wrote the check or deposit and the date that it cleared. I was able to match them to the penny. It was nice to be able to sort by cleared date and I could do a binary search to find where I entered something wrong when balancing. On Mon, Sep 18, 2017 at

Re: [Jprogramming] converting inches to feet, inches (and 16ths of inches)

2017-09-18 Thread Brian Schott
Xiao-Yong and Raul, Thanks for your answers, which are simple and direct. I made the mistake at the outset of trying the following 2 erroneous attempts which pulled me away from #: . 12 12#:166.7 1 10.7 12#:166.7 10.7 --

Re: [Jprogramming] Quora Challenge

2017-09-18 Thread Roger Hui
This particular problem can be solved without resort to extended precision. Use multiplication mod 13, that is, find the remainder at each step rather than waiting until the end: 13&|@* / 19 29 59 79 89 109 119 139 149 179 199 4 On Mon, Sep 18, 2017 at 10:00 AM, Skip Cave

Re: [Jprogramming] idiomatic way for x u"_ 1"1 _ y

2017-09-18 Thread Raul Miller
I'd use x u"1/ y Thanks, -- Raul On Mon, Sep 18, 2017 at 1:03 PM, Rudolf Sykora wrote: > Hello, > > I have found myself writing a pattern like this quite often: > > x u"_ 1"1 _ y > > Is there a more J-idiomatic way to write this, or would you > define a custum

Re: [Jprogramming] converting inches to feet, inches (and 16ths of inches)

2017-09-18 Thread Raul Miller
I'd have done this: 0 12 16#:16*166.7 13 10 11.2 13' 10" and slightly over 11/16. Similar to Xiao-Yong's approach, though slightly different. Thanks, -- Raul On Mon, Sep 18, 2017 at 1:10 PM, Brian Schott wrote: > My car is 166.7 inches long according to the

Re: [Jprogramming] converting inches to feet, inches (and 16ths of inches)

2017-09-18 Thread Xiao-Yong Jin
(_ 12 16#:16&*) 166.7 13 10 11.2 (_ 12 16,%16)#:166.7 13 10 11 0.0125 > On Sep 18, 2017, at 12:10 PM, Brian Schott wrote: > > My car is 166.7 inches long according to the specs. > Car cover coverages are measured in feet and inches. > > To compute how many feet

[Jprogramming] converting inches to feet, inches (and 16ths of inches)

2017-09-18 Thread Brian Schott
My car is 166.7 inches long according to the specs. Car cover coverages are measured in feet and inches. To compute how many feet and inches long my car is I used the following calculations. 166.7%12 13.8917 (-<.)166.7%12 0.891667 12x *(-<.)166.7%12 NB. the x is not required, imo 10.7

[Jprogramming] idiomatic way for x u"_ 1"1 _ y

2017-09-18 Thread Rudolf Sykora
Hello, I have found myself writing a pattern like this quite often: x u"_ 1"1 _ y Is there a more J-idiomatic way to write this, or would you define a custum adverb? (It's basically a table of all 1-cell combinations...) Thanks Ruda

Re: [Jprogramming] Quora Challenge

2017-09-18 Thread Skip Cave
People posting problems on Quora are typically expecting an explicit algebraic formula solution to their problem, though they never explicitly state that requirement. The posted Quora problems often involve very large numbers, which the poster expects will prevent solutions from using a

Re: [Jprogramming] Puzzling result

2017-09-18 Thread Raul Miller
If I had to do that, I'd do it at "reporting time". (Possibly cached, if that turns out to take too long.) Thanks, -- Raul On Mon, Sep 18, 2017 at 9:08 AM, Don Guinn wrote: > I went to one cent and went to a lot of trouble to make sure I rounded the > same way that banks

Re: [Jprogramming] Puzzling result

2017-09-18 Thread Don Guinn
I went to one cent and went to a lot of trouble to make sure I rounded the same way that banks did. On Mon, Sep 18, 2017 at 6:44 AM, Raul Miller wrote: > That depends on what I am doing. > > In professional contexts: I often work with 100 = 1 dollar for > archive

Re: [Jprogramming] Puzzling result

2017-09-18 Thread Don Guinn
So, when you work with money, do you have the number 1 equal to one dollar or one cent? Ten cents is not exact in floating point if you units are dollars. On Mon, Sep 18, 2017 at 5:25 AM, Raul Miller wrote: > There are other cases, always. > > Of course, there are

Re: [Jprogramming] Puzzling result

2017-09-18 Thread Raul Miller
There are other cases, always. Of course, there are examples like bayesian numbers, complex numbers, and quaternions where we indeed generally use integers or floating point numbers under the covers. But we do have high precision rational numbers for cases where that's necessary. Anyways, math

Re: [Jprogramming] Quora Challenge

2017-09-18 Thread Raul Miller
That has been characteristic of Project Euler but Quora Challenges are new to me. Anyways, if the problem expects to answers work with precisions well beyond measurable limits, that should be stated as a part of the problem. Thanks, -- Raul On Sun, Sep 17, 2017 at 2:05 PM, Skip Cave

Re: [Jprogramming] Puzzling result

2017-09-18 Thread Erling Hellenäs
Hi all! I think either we work with integers or with floating point. We use floating point when we have non-countable and  integers when we have countable data. Non countable data is things like measurable quantities in engineering. Countable data is when we count a certain number of things,

Re: [Jprogramming] Quora Challenge

2017-09-18 Thread Erling Hellenäs
I tested with this "primes" function in Nial, but even my first attempt at generating primes in J, The PrimesUntil verb, is considerably better. At 1 primes Nial got in trouble. At 2 primes Nial crashed. https://en.wikipedia.org/wiki/Nial#Explanation /Erling Den 2017-09-17 kl.

Re: [Jprogramming] Quora Challenge

2017-09-18 Thread Erling Hellenäs
ECPP is the best algorithm if you want proof of a correct result for any large number? https://en.wikipedia.org/wiki/Elliptic_curve_primality /Erling Den 2017-09-17 kl. 22:30, skrev Roger Hui: In theory Miller-Rabin can give incorrect result, but the probability of that is lower than the