In the post,

   [Jprogramming] Revisiting the Y combinator
   http://www.jsoftware.com/pipermail/programming/2018-November/052193.html

I wrote,

   The non-tacit version of Y is a transcription of a wicked tacit
   version which I produced using a fork of J which should not be
   mentioned in this forum.

The fork of J is Jx [0] and the wicked tacit version of Y follows after
defining some utilities first,

   NB. Utilities...

   'adv ver' =. _1 _3 <@?: 0
   'x y'     =. [: (@:[<) (@:]<) ]:
   'amper of'=. [: (ver adv&) "..@:([ ; "..^:_1 y) ]:

The Jx tacit version of the Y combinator is (beware of line-wrapping),

   Y=. (< amper f. ])@:(((@:((< amper f. ])@:>x)) (`(of f.`]))
(`:6))ver)@:ver f.

It is a fixed verb,

   wrap=. (_66 ]\ 5!:5@:<@:":)adv

   Y wrap
(< (3?:(<(,'0');&)) ])@:(3?:(<(,'0');((@:((< (3?:(<(,'0');&)) ])@:
>@:[))(`("..@:([ ; "..^:_1@:])`])))(`:6)))@:(_3?:0)

There is no need to use any representations for the adverbs (i.e., the
mappings) because in Jx a monadic verb can operate directly on an adverb
using the form (a v).

   NB. Factorials...

   (@:<:)(*`)(`:6)(1:`)(@.*) Y i.11
1 1 2 6 24 120 720 5040 40320 362880 3628800

The verbs produced are anonymous tacit recursive verbs,

   t=. (@:<:)(*`)(`:6)(1:`)(@.*) Y

   t wrap
(<(3?:(<(,'0');((((@:<:)(*`))(`:6))(1:`))(@.*)))@:((< (3?:(<(,'0')
;&)) ])@:>@:[) "..@:([ ; "..^:_1@:]) ])&((3?:(<(,'0');((((@:<:)(*`
))(`:6))(1:`))(@.*)))@:((< (3?:(<(,'0');&)) ])@:>@:[) "..@:([ ; ".
.^:_1@:]) ])

   NB. Fibonacci numbers...

   rv=. [^:((,'_:') -: ])L:_ 0
   Adv=. (`'') ("_) ((("..^:_1 f.)`(rv f.))`) (`:6) (".. f. @:) f.adv
     erase'rv'
1

   ((_:@:<:@:<: + _:@:<:)^:(1 < ]) Adv Y)"0 i.11
0 1 1 2 3 5 8 13 21 34 55

   t=. (_:@:<:@:<: + _:@:<:)^:(1 < ]) Adv Y

   t wrap
(<(3?:(<(,'0');(1?:(<(,'0');"..@:("..^:_1 [^:('_:' -: ])L:_ 0 (,<(
<'^:'),<(<(<,'3'),<(<(<'@:'),<(<(<'@:'),<;:'_:<:'),<'<:'),(<,'+'),
<(<'@:'),<;:'_:<:'),<(<,'3'),<(<(,'0');1),(<,'<'),<,']')"_)))))@:(
(< (3?:(<(,'0');&)) ])@:>@:[) "..@:([ ; "..^:_1@:]) ])&((3?:(<(,'0
');(1?:(<(,'0');"..@:("..^:_1 [^:('_:' -: ])L:_ 0 (,<(<'^:'),<(<(<
,'3'),<(<(<'@:'),<(<(<'@:'),<;:'_:<:'),<'<:'),(<,'+'),<(<'@:'),<;:
'_:<:'),<(<,'3'),<(<(,'0');1),(<,'<'),<,']')"_)))))@:((< (3?:(<(,'
0');&)) ])@:>@:[) "..@:([ ; "..^:_1@:]) ])

Reference

[0] Jx Extensions
    http://www.2bestsystems.com/foundation/j/jx1.1/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to