[Jprogramming] Recursive verbs

'Pascal Jasmin' via Programming programming at jsoftware.com
Tue Nov 27 12:37:38 UTC 2018


If the verb you want is repetitive double - 1 then
 5 (1 -~ +:@])^:(<@[) 4
4 7 13 25 49
Otherwise, Mike's 2 at a time approach is the way to go.
________________________________
From: Skip Cave <skip at caveconsulting.com>
To: "Programming at jsoftware.com" <Programming at jsoftware.com> 
Sent: Tuesday, November 27, 2018 2:10 AM
Subject: [Jprogramming] Recursive verbs
How would you write an implicit or explicit recursive verb for this
sequence formula?
a1=.4
a1 , (a2=.1-~2*a1) , (a3=.1+~2*a2) , (a4=.1-~2*a3) , (a5=.1+~2*a4) ...
(an=.1(+-)~2*an-1
The verb would be specified as x f y, where x is the starting integer a1,
and y is the number of terms (n) - or vice versa.
The result will be a vector n items long. Note the alternating sign in each
term
Example:
4 f 5
4 7 15 29 59
Skip
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


More information about the Programming mailing list

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