A common objective of many Jx extensions is to unleash the latent power of
an official J interpreter to facilitate the use of higher-order functions
(verbs, adverbs and conjunctions) by providing the means to pass them,
directly, as arguments to other functions.

Arguably, the Dictionary [0] only allows:

  0. Verbs acting on nouns to produce nouns
  1. Adverbs and conjunctions acting on nouns or verbs to produce nouns,
verbs, adverbs or conjunctions

The design reasons for these restrictions are mysterious to me; the most
plausible explanation that I am aware is given in the post [1].

Ever since a back door was opened (an account of the story can be found in
the post[2]) I have been exploring the consequences of embracing high-order
functions in J (and particularly in Jx) from the perspective of tacit
adverbial (and tacit conjunctional) programming.  (Actually, just a few
weeks earlier I had been playing with what is now in Jx v1.0  the train
aspect of  "..  because I thought that complete adverbial programming was
possible with just that facility and it is possible as far as I can see;
this is why I realized immediately that Dan had opened a back door
inadvertently and I rushed through it).  It became apparent very soon to me
that there were many advantages when one can operate tacitly on verbs,
adverbs and conjunctions in a very similar way that one can operate on
nouns.

Years ago I used to write adverbs and conjunctions tacitly via Jx foreigns
using literals (in a similar way that Pascal does it now albeit
explicitly).  I found it painful, in contrast, now it is a joy.  The
appendix shows a sample process.  It might look strange and puzzling; then
again, J programming might look strange and puzzling to the uninitiated.  A
key facility is the (higher-order) verb ?: used at the beginning of the
script to produce the pro-verb  ver  and the pro-adverbs  adv  and  conj.
These, respectively, allow for verbing adverbs and conjuncions, and reduce
tacit adverbial and conjunctional programming to to verbal programming
which happens to be Turing complete.


References

[0] II. Grammar
    http://www.jsoftware.com/help/dictionary/dict2.htm

[1] [Jprogramming] Recursive programming (and scoping therein)  William
Tanksley, Jr
    http://www.jsoftware.com/pipermail/programming/2013-February/031672.html

[2] [Jprogramming] J functional programming extensions  Jose Mario Quintana
    http://www.jsoftware.com/pipermail/programming/2013-March/031883.html


Appendix

The objective is to write a tacit adverb  At  for pipelining verbs with the
premise that space is the best delimiter, for example, given the verbs v0,
... v4

   [: v0 v1 v2 v3 v4 At
v0@:v1@:v2@:v3@:v4

From the high-order functional perspective this should be a matter of
inserting  @:  between the verb arguments; actually, it is with some minor
caveats because verbs and conjunction do not associate the same way and the
default behavior of insert  /  for a single input is not adequate in this
case.

First, a developing session from scratch, that resembles the original
development, is shown; followed by a session with the collected
definition(s) including an example; and last, the collected definition(s)
script.

Beware of line-wrapping!

Developing session...

   JVERSION
Installer: j602a_win.exe
Engine: j806/j64/windows/beta/BEST/Jx/2017-07-27T10:25:25
Library: 6.02.023

   o=. @:
   (;:'ver conj adv')=. _3 _2 _1<@:?:("0) 0

   at=. ver adv @:              NB. Verbing @: (dyadic verb)

   ( G=. [: v0 v1 v2 v3 v4 ]: ) NB. Boxed array of actual (undefined) verbs
for testing
┌──┬──┬──┬──┬──┐
│v0│v1│v2│v3│v4│
└──┴──┴──┴──┴──┘

          at&:"../        G     NB. Dyadic verbs associate to the right...
v0@:(v1@:(v2@:(v3@:v4)))

         (at~&:"../) o |. G     NB. Conjunctions associate to the left
v0@:v1@:v2@:v3@:v4

         (at~&:"../) o |. [:+]: NB. Wrong answer for a single boxed verb...
┌─┐
│+│
└─┘

   ".. o (at~&:"../) o |. [:+]: NB. Right answer
+


   match=. -:&:< conj           NB. Matching words? (conjunction)


   At=. ]: ".. o (at~&:"../) o |. f.adv
                                NB. Pipelining verbs (adverb)
                                NB. Using the extended form (a a) (adverb)
     assert ([:+At) match +
     assert ([: v0 v1 v2 v3 v4 At) match (v0@:v1@:v2@:v3@:v4)


Collected definitions(s) session...

   conj=. _2 ?: 0               NB. Conjunction definition (adverb)
   match=. -:&:< conj           NB. Matching words? (conjunction)

   At=. ]: "..@:((3?:((<'@:')))~&:("..)/)@:|. (_1?:0)
     NB. Pipelining verbs (adverb)
     assert ([:+At) match +
     assert ([: v0 v1 v2 v3 v4 At) match (v0@:v1@:v2@:v3@:v4)

   NB. Example: Farey sequence: http://rosettacode.org/wiki/Farey_sequence#J
...

   Farey=. [:0&,/:~~.(#~ <:&1),%/~x:>:i.At

   Farey
0&,@:(/:~)@:~.@:(#~ <:&1)@:,@:(%/~)@:x:@:>:@:i.
   Farey 5
0 1r5 1r4 1r3 2r5 1r2 3r5 2r3 3r4 4r5 1


Collected definition(s) script...

conj=. _2 ?: 0               NB. Conjunction definition (adverb)
match=. -:&:< conj           NB. Matching words? (conjunction)

At=. ]: "..@:((3?:((<'@:')))~&:("..)/)@:|. (_1?:0)
  NB. Pipelining verbs (adverb)
  assert ([:+At) match +
  assert ([: v0 v1 v2 v3 v4 At) match (v0@:v1@:v2@:v3@:v4)

NB. Example: Farey sequence: http://rosettacode.org/wiki/Farey_sequence#J
...

Farey=. [:0&,/:~~.(#~ <:&1),%/~x:>:i.At

Farey
Farey 5




On Tue, Aug 1, 2017 at 4:55 PM, Jose Mario Quintana <
jose.mario.quint...@gmail.com> wrote:

>
> A brief description of the Jx v1.0 extensions, together with links to a
> Windows 64 bit dll, a Unix 64 bit so binaries and the patch corresponding
> to the J806 source can be found at,
> http://www.2bestsystems.com/foundation/j/jx1
>
> Summary
>
> - Spelling
>   - Names with unicode characters
>   - Primitives
>       Added     =.. =:: $:: [. ]. ]: ".. ":: `. ?: i.. O.
>       Extended  ~ $.
>   - Foreign
>       Added     104!:5 Unnamed Execution
>
> - Trains
>     a v    Added       (different from Jx v0)
>     a a    Extended    (different from Jx v0)
>     c a    Resurrected
>     a c a  Resurrected
>
> The Jx v0 page,
> http://www.2bestsystems.com/foundation/j/jx0
> will be removed in the near future
>
> Time permitting, there will be soon a script with assertions for those who
> want to verify binaries targeted for other platforms and I will try to
> illustrate the facilities in action with some scripts.
>
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to