[Jprogramming] Recursive verbs

Linda Alvord lindaalvord36 at outlook.com
Fri Nov 30 06:18:13 UTC 2018


Here's a little variation. Fibonacci series begins 1 1 ...
Y=: ($:`)(`:6)
N=: 1 :'(u@:<:@:<: + [:u<:)^:(1 < ])'
N=: (5!:1)<'N'
}.N Y("0) i.11
1 1 2 3 5 8 13 21 34 55
Maybe there is a better way to drop the 0.
Linda
-----Original Message-----
From: Programming <programming-bounces at forums.jsoftware.com> On Behalf Of Linda Alvord
Sent: Wednesday, November 28, 2018 4:49 AM
To: programming at jsoftware.com
Subject: Re: [Jprogramming] Recursive verbs
Hi Cliff,
It took a while but I got the explicit verb to work.
f=: 13 :'4 p.~(([:(2&^)>:),.~ _1r3 *([:(2&^)>:) + _1&^)y' 
 
 f i.10
7 15 29 59 117 235 469 939 1877 3755
 
 f
4 p.~ ([: 2&^ >:) ,.~ _1r3 * ([: 2&^ >:) + _1&^
 
Linda
-----Original Message-----
From: Programming <programming-bounces at forums.jsoftware.com> On Behalf Of Cliff Reiter
Sent: Tuesday, November 27, 2018 12:38 PM
To: programming at jsoftware.com
Subject: Re: [Jprogramming] Recursive verbs
I like that solution. Here is another approach
  4 p.~(2&^@>: ,.~ _1r3 * 2&^@>: + _1&^)i. 10
7 15 29 59 117 235 469 939 1877 3755
I found this by composing the linear poly's and noting the constant terms satisfy a two step recursion with eigenvalues 2 and _1.
  lc=.({.@[+{:@[*{.@]),*&{:
  lc/\.(7$_1 2,:1 2)
_43 128
_21 64
_11 32
 _5 16
 _3  8
 _1  4
 _1  2
On 11/27/2018 11:06 AM, Raul Miller wrote:
> Sure, ... that's a bit bulkier than I prefer, but it works.
>> Here's another alternative:
>> evenodd=: , (_1 2,:_1 4)&p.@{:
> evenodd evenodd 4
> 4 7 15 29 59
>> Thanks,
>----------------------------------------------------------------------
For information about J forums see https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Feur04.safelinks.protection.outlook.com%2F%3Furl%3Dhttp%253A%252F%252Fwww.jsoftware.com%252Fforums.htm%26data%3D02%257C01%257C%257C677fb1d024fe4e3d937308d6548f1c93%257C84df9e7fe9f640afb435aaaaaaaaaaaa%257C1%257C0%257C636789370963003978%26sdata%3DiWGjGzFd70epkTr2UBP7DapC8imlNBoaBgTzKw3eTE8%253D%26reserved%3D0&data=02%7C01%7C%7C92114a6817924a16dcb008d65516cce6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636789953739701689&sdata=ory%2FBe7tmba%2BJuewqXZe5BrOSRcxZ0gj68jcNVf3oak%3D&reserved=0
----------------------------------------------------------------------
For information about J forums see https://nam03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=02%7C01%7C%7C92114a6817924a16dcb008d65516cce6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636789953739701689&sdata=%2FoX8rd%2Bm2y8CgviQsIsdy1%2BZBNRQj8b%2BXkDx4p1UXkY%3D&reserved=0


More information about the Programming mailing list

AltStyle によって変換されたページ (->オリジナル) /