Ups! I meant to run the script on an official version but I ended up using
a Jx interpreter. Anyway, it runs on an official J interpreter:
JVERSION
Installer: j602a_win.exe
Engine: j803/2014-10-19-11:11:11
Library: 6.02.023
o=. @:
K=. <;:'&*'
U=. <(<,'&'),<<(":0);1
ku=. K , U ($~) 2 -~ ]
train=. (<'`:')(0:`)(,^:)&6 NB. For compatibility with an official J
an=. <@:((,'0') ,&< ])
(N`A`B)=. < o train"0 (0&{)`(1&{)`(2&{)
hyper=. train o ( ((an o x: o A) < o train o ,(ku o N)) , an o B )f.
hyper 2 2 3 NB. 2 * 3
6
hyper 3 3 2 NB. 3 ^ 2
9
hyper 4 2 5 NB. Tetration
2003529930406846464979072351560255750447825475569751419265016973710894059556311453089506130880933348101038234342907263181822949382118812668869506364761547029165041871916351587966347219442930927982084309104855990570159318959639524863372367203002916969592156...
# ": hyper 4 2 5
19729
hyper 5 3 2 NB. Pentation
7625597484987
hyper 6 1 9 NB. Etc.
1
hyper
,^:(0:``:)&6@:((<@:((,'0') ,&< ])@:x:@:(1&{) <@:(,^:(0:``:)&6)@:,
((<;:'&*') , (<(<,'&'),<<(,'0');1) $~ 2 -~ ])@:(0&{)) , <@:((,'0') ,&<
])@:(2&{))
On Fri, Nov 20, 2015 at 3:23 PM, Jose Mario Quintana <
[email protected]> wrote:
> This is a verb for performing hyper operations:
>
> JVERSION
>
> Engine: j701/2012-12-06/12:20/x
>
> Library: 8.03.14
>
> Qt IDE: 1.3.1/5.3.2
>
> Platform: Win 64
>
> Installer: J803 install
>
> InstallPath: f:/j64-803
>
> o=. @:
>
> K=. <;:'&*'
>
> U=. <(<,'&'),<<(":0);1
>
> ku=. K , U ($~) 2 -~ ]
>
> train=. (<'`:')(0:`)(,^:)&6 NB. For compatibility with an official J
>
> an=. <@:((,'0') ,&< ])
>
> (N`A`B)=. < o train"0 (0&{)`(1&{)`(2&{)
>
> hyper=. train o ( ((an o x: o A) < o train o ,(ku o N)) , an o B )f.
>
> hyper 2 2 3 NB. 2 * 3
>
> 6
>
> hyper 3 3 2 NB. 3 ^ 2
>
> 9
>
> hyper 4 2 5 NB. Tetration
>
>
> 2003529930406846464979072351560255750447825475569751419265016973710894059556311453089506130880933348101038234342907263181822949382118812668869506364761547029165041871916351587966347219442930927982084309104855990570159318959639524863372367203002916969592156108764948889254090805911457037675208500206671563702366126359747144807111774815880914135742720967190151836282560618091458852699826141425030123391108273603843767876449043205960379124490905707560314035076162562476031863793126484703743782954975613770981604614413308692118102485959152380195331030292162800160568670105651646750568038741529463842244845292537361442533614373729088303794601274724958414864915930647252015155693922628180691650796381064132275307267143998158508811292628901134237782705567421080070065283963322155077831214288551675554073345107213112427399562982719769150054883905223804357045848197956393157853510018992000024141963706813559840464039472194016069517690156119726982337890017641517190051133466306898140219383481435426387306539552969691388024158161859561...
>
> # ": hyper 4 2 5
>
> 19729
>
> hyper 5 3 2 NB. Pentation
>
> 7625597484987
>
> hyper 6 1 9 NB. Etc.
>
> 1
>
> hyper
>
> ,^:(0:``:)&6@:((<@:((,'0') ,&< ])@:x:@:(1&{) <@:(,^:(0:``:)&6)@:,
> ((<;:'&*') , (<(<,'&'),<<(,'0');1) $~ 2 -~ ])@:(0&{)) , <@:((,'0') ,&<
> ])@:(2&{))
>
>
> I would left a gramatically correct version as an exercise ;)
>
>
>
>
> On Fri, Nov 20, 2015 at 10:31 AM, Jose Mario Quintana <
> [email protected]> wrote:
>
>> Dan,
>>
>> Check out the message:
>> http://www.jsoftware.com/pipermail/programming/2015-February/041095.html
>> for one easy way to play with Knuth's up arrow notation in J.
>>
>> From there it should be easy to code an alternative version of your
>> adverb H. I never bother to do so because there are just a few numbers, to
>> say the list, that you can actually compute for the hyper operations.
>>
>> As it has been pointed out before, J is relatively slow computing large
>> numbers. Maybe Pascal's package can help but, of course, huge numbers
>> are beyond the computer capabilities of J or any other programming language
>> (in this universe, as is presently known, anyway).
>>
>> On Thu, Nov 19, 2015 at 3:51 PM, Dan Bron <[email protected]> wrote:
>>
>>> The notion of “hyper operation” extends the intuition that
>>> multiplication is repeated addition, exponentiation is repeated
>>> multiplication, tetration is repeated exponentiation, and so on.
>>>
>>> Hyperoperation can be defined piecewise (per Wikipedia) as:
>>>
>>> / b+1 if n = 0
>>> | a if n = 1, b = 0
>>> H_n(a,b) = | 0 if n = 2, b = 0
>>> | 1 if n >= 3, b = 0
>>> \ H_n-1( a, H_n(a, b-1) ) otherwise
>>>
>>> Or, in J:
>>>
>>> H =: adverb define
>>> :
>>> if. 0=m do.
>>> 1+y
>>> elseif. (m > 0) *. (0=y) do.
>>> (<:3<.m) { x,0,1
>>> elseif. do.
>>> x (<:m) H x m H <:y
>>> end.
>>> )
>>>
>>> Now, while J likes 2 (0 H) 3, 2 (1 H) 3, 2 (2 H) 3, and 2 (3 H) 3 just
>>> fine, producing the expected results [1], it silently crashes (i.e. the IDE
>>> simply disappears) on 2 (4 H) 3 .
>>>
>>> Now, I’m sure 2 tetration 3 is some absurdly large number and I
>>> wouldn’t expect a result, but I’d prefer a stack error (or whatever) to a
>>> crash.
>>>
>>> -Dan
>>>
>>> [1] Representing successor, addition, multiplication, and
>>> exponentiation respectively.
>>>
>>>
>>>
>>>
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>>
>>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm