I am surprised to hear that the second solution produces a syntax error in
J604 even taking into account that J604 is quite old.  I am pretty sure it
should work in J701 and definitely works in,

   JVERSION
Engine: j805/j64/windows
Release: commercial/2016-12-11T08:02:16
Library: 8.05.10
Qt IDE: 1.5.3s/5.6.2
Platform: Win 64
Installer: J805 install
InstallPath: c:/program files/j 805
Contact: www.jsoftware.com

   an=.  <@:((,'0') (,&:<) ])  NB. Atomizing words (monadic verb)
   train=. (<'`:')(0:`)(,^:)&6

   f=. train@:([ , an@:]) f.   NB. Non-compliant fixed tacit version

   (*:`+:) f 4
64

It is a non-compliant solution because the verb train does not conform to
the rules of the Dictionary.  In this instance, it seems to behave as any
other ordinary verb acting on a noun (which happens to be a gerund) and
producing a noun,

   train (*:`+: , an 4)
64

However, this non-compliant verb is the counterpart of the adverb train
(`:6) and adverbs (and conjunctions) are capable to produce nouns, verbs
adverbs, and conjunctions.  For example, (`:6) can produce a verb (a hook
in this illustration),

   (*:`+:)(`:6)
*: +:

Consequently, the verb train can also do so even if it should not
(according to the Dictionary's rules),

   train (*:`+:)
*: +:

This kind of verbs makes tacit writing in some instances easy as opposed to
very difficult (if they are forbidden).  Most J programmers avoid them; I
embrace them because I like to write J only tacitly.

The third solution refers to a J fork (Jx) that, among other extensions,
provides additional primitives (and trains) which facilitate the use of
higher order functions directly; see my post [0].

I hope it helps.

[0] Jprogramming] Jx version 1.0 release
    http://www.jsoftware.com/pipermail/programming/2017-August/048117.html


On Sun, Sep 24, 2017 at 2:35 PM, Rob Moore <robmoore...@gmail.com> wrote:

> Thanks for replying Raul, your solutions weren't what I was looking for,
> but I understand the confusion from my first explanation.
>
> Jose your first solution worked perfectly, thanks very much! The other two
> solutions you gave caused syntax errors for me, must be different versions,
> I'm on 604.
>
> What did you mean by compliant and non-compliant in your comments?
>
> Thanks,
>
> Rob
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to