Re: [Jprogramming] Sequence generation

2017-09-29 Thread Raul Miller
Henry Rich wrote: > It could just be that the poster wanted to see a recursive version ... Recursive functions have some inherent complexities - to properly understand them, you need to think about the base case and the recursive case, but you also have to see how that connects to the idea as a wh

Re: [Jprogramming] Sequence generation

2017-09-29 Thread Henry Rich
It could just be that the poster wanted to see a recursive version of this problem (and one using ^:) so that he could learn how to apply those methods to other problems that really needed them. Henry Rich On 9/29/2017 11:01 PM, Don Kelly wrote: So it is a game- fair enough- it shows that in J

Re: [Jprogramming] Sequence generation

2017-09-29 Thread Don Kelly
So it is a game- fair enough- it shows that in J there are more ways than one to skin a cat. BUT does it really bring out the reason for a language like J or APL? Does it bring out the power of J to make so many things simpler and more elegant for the user? You have used APL and so have I -and

Re: [Jprogramming] Sequence generation

2017-09-29 Thread Don Guinn
Actually this can be done without loss of precision. I cheat a lot of times when asked to generate a function that matches a series. If the series is a polynomial simply solve for the coefficients. z=.4 9 15 22 30 39 49 60 72 85 z%.(i.#z)^/i.6x 4 9r2 1r2 0 0 0 ---

Re: [Jprogramming] Sequence generation

2017-09-29 Thread 'Mike Day' via Programming
Yes - nice - it's related to the result: ti = 4i + i(i-1)%2 , discussed in my message, with t0 = 0, although you're doing the equivalent of ti = 4(i+1) + i(i+1)%2, with t0 = 4, here. Beware loss of precision on long sequences, though, as the default datatype is floating, and given all the

Re: [Jprogramming] Sequence generation

2017-09-29 Thread Don Guinn
Here is another way: 4 4.5 0.5 p. i.10 4 9 15 22 30 39 49 60 72 85 On Fri, Sep 29, 2017 at 3:32 AM, 'Mike Day' via Programming < programm...@jsoftware.com> wrote: > Linda offers: > f=: 13 :'+/"1(>:/~i.y)*(y#x)+/i.y' NB. (msgsbelow) > > My best f , with an [: for Linda's sake: >f =: ([:+/

Re: [Jprogramming] Sequence generation

2017-09-29 Thread 'Mike Day' via Programming
Linda offers: f=: 13 :'+/"1(>:/~i.y)*(y#x)+/i.y' NB. (msgsbelow) My best f ,  with an [: for Linda's sake:    f =: ([:+/\ (+i.))    4 f 7 4 9 15 22 30 39 49 HOWEVER, although Skip initially asked for a way to render 4, (4+5), (4+5+6),  ... recursively, we may consider that the (i+1)th term may b

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Don Kelly
Fair enough -he did ask for a recursive form. summing  is similar to the non recursive method for forming "sin" from  a series . In other words- why go to recursive- shades of Basic, Fortran and other languages needing a loop for this. It is a bit of beating a dead horse. Don On 2017-09-28 4

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Skip Cave
doh! +/\4+i.10 4 9 15 22 30 39 49 60 72 85 O ​f course​! I should have seen that. Actually, I thought that a recursive approach would be simpler/more concise, but that doesn't seem to be the case. Skip Cave Cave Consulting LLC On Thu, Sep 28, 2017 at 8:57 PM, Linda Alvord wrote: > Or: > f=: 1

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Linda Alvord
Or: f=: 13 :'+/"1(>:/~i.y)*(y#x)+/i.y'    4 f 7 4 9 15 22 30 39 49    Linda Sent from AOL Mobile Mail On Thursday, September 28, 2017 Raul Miller wrote: Nothing is simpler than the i. approach, but ^: is not significantly more complex than $: approach: }:(}:,+/@(_2&{.),>:@{:)^:9]4 4 9 15 22 30

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Linda Alvord
Or: f=: 13 :'+/"1(>:/~i.y)*(y#x)+/i.y'    4 f 7 4 9 15 22 30 39 49    Earlier message from tablet and this from phone. Linda Linda Sent from AOL Mobile Mail On Thursday, September 28, 2017 Raul Miller wrote: Nothing is simpler than the i. approach, but ^: is not significantly more complex t

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Linda Alvord
How about? f=: 13 :'+/"1(>:/~i.y)*(y#x)+/i.y' 4 f 7 4 9 15 22 30 39 49 Linda Sent from AOL Mobile Mail On Thursday, September 28, 2017 Raul Miller wrote: Nothing is simpler than the i. approach, but ^: is not significantly more complex than $: approach: }:(}:,+/@(_2&{.),>:@{:)^:9]

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Björn Helgason
'0' -.~ ,'),',"1~ '(',"1 ": +\4+i.10 just add + here and there On 28 Sep 2017 18:34, "Skip Cave" wrote: > What is a good way to generate this sequence in J? > > 4,(4+5),(4+5+6),(4+5+6+7),(4+5+6+7+8)+. > > Show one way using i. and insert. > > Show another way using recursion. > > Skip > >

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Erling Hellenäs
It's not better. Skip asked for a recursive version too so  we gave him one. Very complicated way to write a simple thing. Lol. /Erling On 2017-09-29 01:24, Don Kelly wrote: why is this better than the easy to read version that Roger Hui sent? quote:    +/\4+i.10 4 9 15 22 30 39 49 60 72 85

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Don Kelly
why is this better than the easy to read version that Roger Hui sent? quote: +/\4+i.10 4 9 15 22 30 39 49 60 72 85 unquote: This is also the way APL does it Sure it is fun to try different ways such as below, just as it is fun to make a 1 liner to generate a series for sin x. It is also ni

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Raul Miller
Nothing is simpler than the i. approach, but ^: is not significantly more complex than $: approach: }:(}:,+/@(_2&{.),>:@{:)^:9]4 4 9 15 22 30 39 49 60 72 Thanks, -- Raul On Thu, Sep 28, 2017 at 3:37 PM, Xiao-Yong Jin wrote: > > >> On Sep 28, 2017, at 1:40 PM, Raul Miller wrote: >> >> Tha

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Xiao-Yong Jin
> On Sep 28, 2017, at 2:45 PM, Erling Hellenäs wrote: > >4 [`(] (] , [ + [: {: ]) [ $: [: <: ])@.(<) 8 > 4 9 15 22 30 Super! 4 [`(] (] , (+{:)) ($:<:) )@.< 8 > /Erling > > On 2017-09-28 20:33, Skip Cave wrote: >> What is a good way to generate this sequence in J? >> >> 4,(4+5),(4+5+6)

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Erling Hellenäs
   4 [`(] (] , [ + [: {: ]) [ $: [: <: ])@.(<) 8 4 9 15 22 30 /Erling On 2017-09-28 20:33, Skip Cave wrote: What is a good way to generate this sequence in J? 4,(4+5),(4+5+6),(4+5+6+7),(4+5+6+7+8)+. Show one way using i. and insert. Show another way using recursion. Skip Skip Cave Cav

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Xiao-Yong Jin
> On Sep 28, 2017, at 2:37 PM, Xiao-Yong Jin wrote: > > > >> On Sep 28, 2017, at 1:40 PM, Raul Miller wrote: >> >> That is what I would assume: >> >> 4,(4+5),(4+5+6),(4+5+6+7),(4+5+6+7+8) >> 4 9 15 22 30 >> >> I was trying to figure out a recursive approach which isn't vastly >> more ted

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Xiao-Yong Jin
> On Sep 28, 2017, at 1:40 PM, Raul Miller wrote: > > That is what I would assume: > > 4,(4+5),(4+5+6),(4+5+6+7),(4+5+6+7+8) > 4 9 15 22 30 > > I was trying to figure out a recursive approach which isn't vastly > more tedious... 4( [, +( ([,+)`$:@.(10>]) ) >:@])5 On the other hand, ^: can

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Raul Miller
That is what I would assume: 4,(4+5),(4+5+6),(4+5+6+7),(4+5+6+7+8) 4 9 15 22 30 I was trying to figure out a recursive approach which isn't vastly more tedious... Thanks, -- Raul On Thu, Sep 28, 2017 at 2:39 PM, Roger Hui wrote: > You don't mean > >+/\4+i.10 > 4 9 15 22 30 39 49 60 7

Re: [Jprogramming] Sequence generation

2017-09-28 Thread Roger Hui
You don't mean +/\4+i.10 4 9 15 22 30 39 49 60 72 85 do you? On Thu, Sep 28, 2017 at 11:33 AM, Skip Cave wrote: > What is a good way to generate this sequence in J? > > 4,(4+5),(4+5+6),(4+5+6+7),(4+5+6+7+8)+. > > Show one way using i. and insert. > > Show another way using recursion.

[Jprogramming] Sequence generation

2017-09-28 Thread Skip Cave
What is a good way to generate this sequence in J? 4,(4+5),(4+5+6),(4+5+6+7),(4+5+6+7+8)+. Show one way using i. and insert. Show another way using recursion. Skip Skip Cave Cave Consulting LLC -- For information about J