Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Jose Mario Quintana
Right, I remember now you mentioned that visualization tool before. It turns out that Skip function actually was, f=. 8 + (2 ^ ]) - (2 ^ 2) ^ ] instead of, g=. 8 + (2 ^ ]) - 2 ^ 2 ^ ] which I was entertaining earlier last night. Coincidentally, today I was exploring some solutions for f...

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Louis de Forcrand
Indeed I should’ve mentioned it; I was referring to my earlier message: 0 = (4^z) - (2^z) - 8 = _8 _1 1 p. 2^z so 2^(x+iy) = z = (1 +- (%:33))/2. The rest should be clearer now. Thanks, Louis > On 29 Jan 2018, at 18:43, Raul Miller wrote: > > I do not know which of j expressions which could

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Raul Miller
I do not know which of j expressions which could have matched original expression you were referring to. Thanks, -- Raul On Mon, Jan 29, 2018 at 12:39 PM, Louis de Forcrand wrote: > Yes, typed a little fast. > > sqrt33 = %:33. > > Why does it not make sense? > > Louis > >> On 29 Jan 2018, at

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Louis de Forcrand
Yes, typed a little fast. sqrt33 = %:33. Why does it not make sense? Louis > On 29 Jan 2018, at 18:35, Raul Miller wrote: > > What is sqrt33 here? (I would have guessed %:33 but that does not make > sense to me.) > > Thanks, > > -- > Raul > > >> On Mon, Jan 29, 2018 at 12:31 PM, Louis de

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Louis de Forcrand
I would recommend using D. instead of d. in general for more complicated or explicit verbs. (lower case) d. assumes your verb is a scalar verb and tries to perform a symbolic differentiation on tacit verbs only, while D. differentiates numerically. Not all verbs can be differentiated with d., b

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Skip Cave
Louis mentions a different Newton Raphson verb: VN=: 1 : 0 - u %. u D.1 ) This one works on either form of the equation: v =: 3 : '8 + (2^y) - (2^2*y)' vv =: (8: + (2&^) - (2&^)@(2&*)) vv VN (^:20) 1 1.75372489415532 v VN (^:20) 1 1.75372489415532 Skip Skip Cave Cave Consultin

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Raul Miller
What is sqrt33 here? (I would have guessed %:33 but that does not make sense to me.) Thanks, -- Raul On Mon, Jan 29, 2018 at 12:31 PM, Louis de Forcrand wrote: > I skipped a few steps there. With pencil and paper, I find that (using > standard notation) > > 2^(x+iy) = (1 +- sqrt(33)) / 2 > >

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Raul Miller
A rule I was working with was that if the individual terms were differentiable, then their sums would be differentiable. This turns out to be slightly more rigorous than what's actually required: 8: d. 1 0"0 8 d. 1 |nonce error but (8 + ]) d. 1 1x"0 In other words, 8: is a verb that d

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Louis de Forcrand
I skipped a few steps there. With pencil and paper, I find that (using standard notation) 2^(x+iy) = (1 +- sqrt(33)) / 2 Yet 2^(x+iy) = 2^x * 2^iy, and because the whole is real, 2^iy must be real. Moreover, when y is such that 2^iy is real (when y is a multiple of Pi/log2) then 2^iy = exp(lo

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread 'Bo Jacoby' via Programming
What does 'best' method mean? Bisection is OK f=. 3 : '(-2^2^y) + (2^y) +8' f 1.818415 1.81842 1.61514e_5 _6.92891e_5 Den 16:04 mandag den 29. januar 2018 skrev Raul Miller : Oops, yes, sorry, careless of me. Thanks, -- Raul On Mon, Jan 29, 2018 at 4:12 AM, Rob Hodgkinson wrote

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Skip Cave
What are the rules required to re-format a verb to make it processable by N? The original equation: (2^x) - 2^2*x = _8 The reformatted equation: (8: + (2&^) - (2&^)@(2&*)) Why the colon? Why the @ sign? Why the ampersand? Why not make a monadic verb?: v =: 3 : '8 + (2^y) - (2^2*y)' vv =: (8

[Jprogramming] Another Quora Problem

2018-01-29 Thread Andrew Nikitin
Jose Mario Quintana wrote: > but, it is not the only one, > > (X=. (8 + (2 ^ ]) - (2 ^ 2) ^ ])New (^:22) 0.5j_0.5) > 1.24627511j4.53236014 There is way more than that. If you use "phase portrait visualization tool" (e.g. from here http://code.jsoftware.com/wiki/User:Andrew_Nikitin/Phase_port

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Raul Miller
Oops, yes, sorry, careless of me. Thanks, -- Raul On Mon, Jan 29, 2018 at 4:12 AM, Rob Hodgkinson wrote: > Minor correction Raul (- instead of +) ? > ... use (8: + (2&^) - (2&^)@(2&*)) > > So Skip, just to clarify to see this solution put through Newton-Raphson; > > 1) Create the Newton-Ra

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Rob Hodgkinson
Minor correction Raul (- instead of +) ? ... use (8: + (2&^) - (2&^)@(2&*)) So Skip, just to clarify to see this solution put through Newton-Raphson; 1) Create the Newton-Raphson adverb as you stated earlier; N=: 1 : '- u % u d. 1’ 2) Apply for a number of iterations using ^: and give i

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Raul Miller
d. 1 wants to be able to use the chain rule for 2^2*x, and it seems like the implementation was from an early version of J, and has not kept up with all the more recent changes. So, you should put that changed term into an f@g form. In other words, use (8: + (2&^) + (2&^)@(2&*)) Thanks, -- Raul

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Louis de Forcrand
Note that if the equation really is (in traditional notation) 4^x - 2^x - 8 = 0 then it can be rewritten as y^2 - y - 8 = 0, y = 2^x and solved in closed form as well, yielding a countably infinite set of solutions aligned along one (or two) vertical lines in the complex plane. (If I am not mi

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Skip Cave
I see what I did wrong. The equation is: 8 + (2^x) - 2^2*x = 0 The third term is (2^2*x) not (2^2^x) That should get close to the answer x=1.75372 I'm mostly interested in how to formulate the code to implement the Newton Raphson solution using N=: 1 : '- u % u d. 1' In the NR code, where d

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Rob Hodgkinson
@Skip et al … also apologies for my sill definitions, I should have used y inside the definitions not x (!!!), sorry if I confused the issue… as in here for the first interpretation … x,"0 (3 : '8+(2^y)-((2^2)^y)') x=:1.6+0.05*i.8 …/Rob > On 29 Jan 2018, at 3:49 pm, Jose Mario Quintana > wr

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Jose Mario Quintana
In that case, (X=. (8 + (2 ^ ]) - (2 ^ 2) ^ ])New (^:22) 1) 1.75372489 is a root, (8 + (2 ^ ]) - (2 ^ 2) ^ ])X 0 but, it is not the only one, (X=. (8 + (2 ^ ]) - (2 ^ 2) ^ ])New (^:22) 0.5j_0.5) 1.24627511j4.53236014 (8 + (2 ^ ]) - (2 ^ 2) ^ ])X 8.8817842e_16j7.72083702e_15 On

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Raul Miller
Hmm... I had originally thought about calling out the (2^2)^x interpretation as a possibility, because rejected that, because that would be better expressed as 4^x But it's possible that Skip got the 1.75379 number from someone who thought different about this. And, to be honest, it is an ambigu

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Rob Hodgkinson
@Skip Skip, I am a confused in your original post… your actual post read; What is the best iterative way to solve this equation: (-2^2^x) + (2^x) +8 =0 then later to Raul, 0 = 8 + (2^x) - 2^2^xNB. Is correct, and the answer is real The answer i

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Jose Mario Quintana
Moreover, apparently there is at least another solution, ((-2^2^X) + (2^X) +8 ) [ X=. 2.9992934709539156j_13.597080425481581 5.19549681e_16j_2.92973749e_15 On Sun, Jan 28, 2018 at 7:28 PM, Jose Mario Quintana < jose.mario.quint...@gmail.com> wrote: > Are you sure? > >u New > - (u %. u D

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Jose Mario Quintana
Are you sure? u New - (u %. u D.1) ,. (8 + (2 ^ ]) - 2 ^ 2 ^ ])New (^:(<22)) 1 1 3.44167448 3.25190632 3.03819348 2.7974808 2.53114635 2.25407823 2.00897742 1.86069674 1.82070294 1.81842281 1.81841595 1.81841595 1.81841595 1.81841595 1.81841595 1.81841595 1.81841595 1.81841595 1.8

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Louis de Forcrand
Since Newton-Raphson is mentioned, I’d like to throw in (even though it might be mentioned on the wiki page) that VN=: 1 : 0 - u %. u D.1 ) is a kind of holy grail. It can iteratively find roots not only of complex scalar functions, but also complex vector and even tensor functions I belie

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Raul Miller
Yeah, I guess it should be fine to just look at the sequence to see if it's converging, or test the result. My thought was that iterations are cheap, I just wanted a small finite number of them. Thanks, -- Raul On Sun, Jan 28, 2018 at 6:05 PM, Henry Rich wrote: > If Newton's method converges,

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Raul Miller
Oh, yes... I see the problem: 13 :' 8 + (2^y) - 2^2^y' 8 + (2 ^ ]) - 2 ^ 2 ^ ] 13 :' 8 + (2^y) - 2^2^y' d.1 |domain error Instead, use: 8: + 2&^ + (2&^)@(2&^) Thanks, -- Raul On Sun, Jan 28, 2018 at 5:52 PM, Skip Cave wrote: > Raul, > > You had it right in the first place. > > 0 =

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Henry Rich
If Newton's method converges, you won't need a couple of hundred rounds - just a dozen or so. Henry Rich On 1/28/2018 5:52 PM, Skip Cave wrote: Raul, You had it right in the first place. 0 = 8 + (2^x) - 2^2^xNB. Is correct, and the answer is real The answer is close to 1.75379 I wanted

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Skip Cave
Raul, You had it right in the first place. 0 = 8 + (2^x) - 2^2^xNB. Is correct, and the answer is real The answer is close to 1.75379 I wanted to know how to construct the Newton Raphson method using the iteration verb N described in the link: http://code.jsoftware. com/wiki/NYCJUG/2010-11-

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Raul Miller
Eh... I *think* you meant what would be expressed in J as: 0 = 8 + (2^x) - 2^2^x I'd probably try maybe a few hundred rounds of newton's method first, and see where that leads. But there's an ambiguity where the original expression (depending on the frame of reference of the poster) could have b

[Jprogramming] Another Quora Problem

2018-01-28 Thread Skip Cave
What is the best iterative way to solve this equation: (-2^2^x) + (2^x) +8 =0 Skip Cave Cave Consulting LLC -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Another Quora problem

2017-12-20 Thread Erling Hellenäs
My take:   (((0=60|])*.0~:24|])#])1+i.1000 60 180 300 420 540 660 780 900 /Erling Den 2017-12-19 kl. 19:52, skrev 'Skip Cave' via Programming: How many numbers from 1 to 1000 are divisible by 60 but not by 24? Here's my somewhat inelegant explicit solution: #e=.c#~d=.-.0=24|/c=.a#~b=.0=

Re: [Jprogramming] Another Quora problem

2017-12-19 Thread Raul Miller
Here's another approach: f=: [ * i.@<.@%~ 60 -.&(f&1000) 24 60 180 300 420 540 660 780 900 Of course, you could easily replace f with it definition (in parenthesis), since it's referenced only once. But this way it's easy to see what f is doing: 60 f 1000 0 60 120 180 240 300 360 420 4

Re: [Jprogramming] Another Quora problem

2017-12-19 Thread 'Skip Cave' via Programming
Jimmy's solution is nice, and fast as well. It answers the question that was posed, but I usually like to list the resulting numbers, just as a check. Of course, it's easy to get the resulting numbers using Jimmy's approach (which is also faster than the bulk elimination approach.) a#~*24|a=

Re: [Jprogramming] Another Quora problem

2017-12-19 Thread Jimmy Gauvin
​​Explicit (and faster for larger range) : +/*24|60*i.>:<.1000%60 8 In this specific case is tacit necessary? useful? On Tue, Dec 19, 2017 at 1:52 PM, 'Skip Cave' via Programming < programm...@jsoftware.com> wrote: > How many numbers from 1 to 1000 are divisible by 60 but not by 24? >

Re: [Jprogramming] Another Quora problem

2017-12-19 Thread chris burke
> I.1=#.|:0=24 60 |/i.1001 Slightly simpler: I. wrote: > Here's one approach: > >I.1=#.|:0=24 60 |/i.1001 > 60 180 300 420 540 660 780 900 > > Thanks, > > -- > Raul > > > On Tue, Dec 19, 2017 at 1:52 PM, 'Skip Cave' via Programming > wrote: > > How many numbers from 1 to 1000 are divisible

Re: [Jprogramming] Another Quora problem

2017-12-19 Thread 'Skip Cave' via Programming
Thanks for the several nice solutions to the Quora problem. On Quora, most of the solutions to this type of problem are like Mike Day's approach, where they use logic to finesse the answer. I prefer the "brute force" approach, listing and eliminating candidates in bulk. J's array-handling primitiv

Re: [Jprogramming] Another Quora problem

2017-12-19 Thread Raul Miller
Here's one approach: I.1=#.|:0=24 60 |/i.1001 60 180 300 420 540 660 780 900 Thanks, -- Raul On Tue, Dec 19, 2017 at 1:52 PM, 'Skip Cave' via Programming wrote: > How many numbers from 1 to 1000 are divisible by 60 but not by 24? > > Here's my somewhat inelegant explicit solution: > >

Re: [Jprogramming] Another Quora problem

2017-12-19 Thread Henry Rich
   numaliquotsbelow =: <.@(%~ <:)    1000 -&(60&numaliquotsbelow - (60*.24)&numaliquotsbelow) 60 8    1000 -&(60&numaliquotsbelow - (60*.24)&numaliquotsbelow) 59 8    1000 -&(60&numaliquotsbelow - (60*.24)&numaliquotsbelow) 61 7    1000 -&(60&numaliquotsbelow - (60*.24)&numaliquotsbelow) 1 8 Henr

Re: [Jprogramming] Another Quora problem

2017-12-19 Thread 'Mike Day' via Programming
    q:24 60 2 2 2 3 2 2 3 5 So we can see that odd multiples of 60 are not divisible by 24,  while even ones are.    1000 >.@% 60 17 shows that there are 16 multiples of 60,  <: 1000 and greater than zero. 8 of these are even, divisible by 24,  and 8 odd,  not divisible by 24 .     60*1

[Jprogramming] Another Quora problem

2017-12-19 Thread 'Skip Cave' via Programming
How many numbers from 1 to 1000 are divisible by 60 but not by 24? Here's my somewhat inelegant explicit solution: #e=.c#~d=.-.0=24|/c=.a#~b=.0=60|/a=.1+i.1000 8 NB. What are the numbers? e 60 180 300 420 540 660 780 900 How would I construct a more compact tacit solution? Skip

Re: [Jprogramming] Another Quora Problem

2017-09-04 Thread Don Kelly
correction sum=: ]1+] for even numbers only from 2 to n%2 For numbers from 1 to n the sum is (n+1)*n%2 . In the case that you give  x= sum of a+ (n-1)b,    which should be a+sum(n-1*b)  which can be simplified to a +b(1+2+3+..n-1)which becomes a +b*n*(n-1)%2  As you are considering a +(a+b)+ (

Re: [Jprogramming] Another Quora Problem

2017-08-31 Thread Don Kelly
The pairing eliminates the brute force  summing of the series. This is what Gauss found. In the case of only even numbers from 2 to n , this works. In the case of 42 there are 21 even numbers of which 20 can be paired off pairs 2+42,4+40 etc, each averaging 22 and there is an unpaired number wh

Re: [Jprogramming] Another Quora Problem

2017-08-30 Thread Xiao-Yong Jin
> On Aug 30, 2017, at 10:43 PM, Don Kelly wrote: > > I agree with your opinion of what Skip wrote. looking back to Gauss and > figuring out the symmetry works for both odd and even cases (42 &43 for > example. However in his statement the numbers are 1...21 where the numbers > are 2 to 42 a

Re: [Jprogramming] Another Quora Problem

2017-08-30 Thread Don Kelly
I agree with your opinion of what Skip wrote.  looking back to Gauss and figuring out the symmetry works for both odd and even cases (42 &43 for example. However in his statement the numbers are 1...21 where the numbers are 2 to 42  all even numbers- the result is still 21*22 . 42%2 is 21 which

Re: [Jprogramming] Another Quora Problem

2017-08-30 Thread 'Mike Day' via Programming
Good points,  Skip. Mind you,  I've learnt (and then forgotten again) a lot of J AND maths doing Euler probs. Keep sharing, Thanks, Mike On 29/08/2017 20:48, Skip Cave wrote: Project Euler problems typically assume the use of a computer. Thus the problems are often posed in a way that ma

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Don Kelly
Did anyone try these? +/2*1+i.21 462 +/2*i.22 462 Don Kelly On 2017-08-29 6:17 AM, Murray Eisenberg wrote: The sum in question is twice the sum of the integers from 1 to 21. By the well-known formula (sometimes attributed to Gauss), the latter sum is half the product of 21 and 21 + 1,

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Ric Sherlock
Hi Harvey, I haven't used it but the 'debug/tte' addon available in Package Manager has the following description: Addon: tte is an adverb to "explicate" a given tacitly-defined verb by generating an explanatory explicit definition from the given tacit definition. The result is a working verb which

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread PR PackRat
On 8/29/17, Roger Hui wrote: > The version I heard was that the math teacher wanted to have a rest, so > assigned +/1+i.100 to the class. Gauss got the answer right away. The rest > of the class labored for the entire hour. The only correct answer was > submitted by Gauss. Roger's version of the

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Skip Cave
Project Euler problems typically assume the use of a computer. Thus the problems are often posed in a way that makes brute-force computer solutions impractical, even when using fairly powerful machines. This forces Project Euler problem-solvers to seek algorithmic approaches that avoid large amount

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Roger Hui
The version I heard was that the math teacher wanted to have a rest, so assigned +/1+i.100 to the class. Gauss got the answer right away. The rest of the class labored for the entire hour. The only correct answer was submitted by Gauss. On Aug 29, 2017 3:28 PM, "'Mike Day' via Programming" < prog

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread HenryRich
You meant    21 ^!.1 (2) Henry Rich On 8/29/2017 12:36 PM, Roger Hui wrote: Oops, off by a factor of 2. On Aug 29, 2017 13:34, "Roger Hui" wrote: 2!>:21 On Aug 29, 2017 10:17, "Murray Eisenberg" wrote: The sum in question is twice the sum of the integers from 1 to 21. By the well-kno

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread 'Mike Day' via Programming
At the risk of getting too chatty,  I'd point out that in the majority of Project Euler problems*,  while you can (sometimes) explore the foothills of the challenge, including example solutions provided,  with a brute-force approach, it is generally necessary to find ways to avoid requiring too

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Roger Hui
Oops, off by a factor of 2. On Aug 29, 2017 13:34, "Roger Hui" wrote: > 2!>:21 > > > > On Aug 29, 2017 10:17, "Murray Eisenberg" wrote: > >> The sum in question is twice the sum of the integers from 1 to 21. By the >> well-known formula (sometimes attributed to Gauss), the latter sum is half >>

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Roger Hui
2!>:21 On Aug 29, 2017 10:17, "Murray Eisenberg" wrote: > The sum in question is twice the sum of the integers from 1 to 21. By the > well-known formula (sometimes attributed to Gauss), the latter sum is half > the product of 21 and 21 + 1, so the sum in question is > > */21+i. 2 > 462 > >

[Jprogramming] Another Quora Problem

2017-08-29 Thread Murray Eisenberg
The sum in question is twice the sum of the integers from 1 to 21. By the well-known formula (sometimes attributed to Gauss), the latter sum is half the product of 21 and 21 + 1, so the sum in question is */21+i. 2 462 > On28 Aug 2017 12:02:57 -0500,S kip Cave

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Rob Hodgkinson
Further to Louis’ comment Skip, I think you might be confusing how the parens ( ) affect the “verb train”. A simple example: x=:3 5 8 12 +/ % # x 0.25 NB. The above line without parens is just +/ (sum) of the % (reciprocal) of the # (tally) of x … so reduces as follows +/ % 4 +/

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Louis de Forcrand
Stick a pair of parens around the hook, otherwise it executes like any explicit sentence! Louis > On 29 Aug 2017, at 11:33, Skip Cave wrote: > > Louis: > > This works: > > +/(#~[:-.2&|)i.43 > > 462 > > > This doesn't: > > +/#~ -.@:(2&|)i.43 > > 22 > > Skip Cave > Cave Consultin

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Skip Cave
Louis: This works: +/(#~[:-.2&|)i.43 462 This doesn't: +/#~ -.@:(2&|)i.43 22 Skip Cave Cave Consulting LLC On Tue, Aug 29, 2017 at 4:17 AM, Louis de Forcrand wrote: > Also count the verbs in > > #~ -. 2&| > > With three verbs this evaluates to a fork, so > > (#~ -. 2&|) v > (#~

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Louis de Forcrand
Also count the verbs in #~ -. 2&| With three verbs this evaluates to a fork, so (#~ -. 2&|) v (#~v) -. 2&|v which signals a length error because #~ changes the shape of its argument. What you want is to apply -. mondadically to 2&|, not apply it between #~ and 2&|; to do so use a cap [: like

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Raul Miller
You should be using #~ instead of # If you look at your intermediate result without the +/ you will see why. Thanks, -- Raul On Tue, Aug 29, 2017 at 4:04 AM, Skip Cave wrote: > There seems to be two basic approaches to this problem: > > 1. Generate the even numbers between 1 & 42, and add th

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Skip Cave
There seems to be two basic approaches to this problem: 1. Generate the even numbers between 1 & 42, and add them up. 2. Use the formula for the sum of an arithmetic progression - e.g.: Sum=n(a+b)/2 *n* = number of numbers in the sequence (here 21) *a* = the first number in the sequence (here 2)

Re: [Jprogramming] Another Quora Problem

2017-08-28 Thread PR PackRat
On 8/28/17, Jose Mario Quintana wrote: > You can try Zsban Ambrus' TacitToExplict script [0] "It's not perfect, so > some strange verbs might not work." > I hope it helps. > > [0] Scripts/TacitToExplicit Zsban Ambrus > http://code.jsoftware.com/wiki/Scripts/TacitToExplicit Thanks for this ci

Re: [Jprogramming] Another Quora Problem

2017-08-28 Thread Jose Mario Quintana
You can try Zsban Ambrus' TacitToExplict script [0] "It's not perfect, so some strange verbs might not work." However, test=. [: +/ ([: -. 2 | ]) # ] test tte 3 : 0 t0=. -. (2) | y s0=. t0 # y (+/)s0 ) test tte (1+i.42) 462 I hope it helps. [0] Scripts/TacitToExplicit Zsban Ambrus

Re: [Jprogramming] Another Quora Problem

2017-08-28 Thread Louis de Forcrand
Not built-in to the language. You could pretend to be the computer and expand tacit code yourself while referring to the dictionary, renaming chunks to help you. Otherwise there might be some code somewhere that does this, but I don't know of it. Good luck, Louis > On 29 Aug 2017, at 00:00, P

Re: [Jprogramming] Another Quora Problem

2017-08-28 Thread PR PackRat
Dear Group: On 8/28/17, Jose Mario Quintana wrote: > The tacit translator was my faithful teacher a long time ago and I still > use it occasionally, nowadays to understand non-tacit code. Is there any translator (or is it impossible?) to go the opposite way, that is, tacit to explicit? At my ba

Re: [Jprogramming] Another Quora Problem

2017-08-28 Thread Jose Mario Quintana
"I'm sure this can be done in a single line using a hook or fork. but I'm not clear enough with the train rules to put this all together on a single line." One can always ask the tacit translator (if worst come to worst one would get an explicit answer back). 13 : '+/(-.2|a)#a [ a=.>:i.42' [:

Re: [Jprogramming] Another Quora Problem

2017-08-28 Thread HenryRich
   ^!.1&2&-: 42    (2!>:)&.-: 42 Henry Rich On 8/28/2017 2:48 PM, Raul Miller wrote: Oops, I thought I had included that one. Thanks, -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Another Quora Problem

2017-08-28 Thread Raul Miller
Oops, I thought I had included that one. Thanks, -- Raul On Mon, Aug 28, 2017 at 1:37 PM, 'Mike Day' via Programming wrote: > What about using some Maths? > E.g. > (*>:)@-:42 > 462 > > Mike > > Please reply to mike_liz@tiscali.co.uk. > Sent from my iPad > >> On 28 Aug 2017, at 18:12, Raul

Re: [Jprogramming] Another Quora Problem

2017-08-28 Thread Jimmy Gauvin
Hi, I think they want a formula like the one to sum the first n integers (n*(n+1))/2. For the sum of even integers up to 42 in J that would be: (*>:) -: 42 462 For the sum of even integers up to n : (*>:) <. -: i.43 0 0 2 2 6 6 12 12 20 20 30 30 42 42 56 56 72 72 90 90 110 110 132 132

Re: [Jprogramming] Another Quora Problem

2017-08-28 Thread 'Mike Day' via Programming
What about using some Maths? E.g. (*>:)@-:42 462 Mike Please reply to mike_liz@tiscali.co.uk. Sent from my iPad > On 28 Aug 2017, at 18:12, Raul Miller wrote: > > Well... the simplest J implementation for that problem would be: > > 462 > 462 > > But there are other ways of ge

Re: [Jprogramming] Another Quora Problem

2017-08-28 Thread Raul Miller
Well... the simplest J implementation for that problem would be: 462 462 But there are other ways of getting that result: +/(* 0 = 2&|)1+i.42 462 +/(* 0 = 2&|)i.43 462 +/2*i.>:-:42 462 +/2*1+i.21 462 +/2*i.22 462 and... so on... I suppose a part of the question is: what is ac

[Jprogramming] Another Quora Problem

2017-08-28 Thread Skip Cave
A simple problem posted on Quora: What is the sum of all the even numbers from 2 to 42? My J solution: a=:>:i.42 +/(-.2|a)#a 462 I'm sure this can be done in a single line using a hook or fork. but I'm not clear enough with the train rules to put this all together on a single line. Any sugg