Here's my version of a alternative, possibly more readable example. It's
likely excessive and unconventional:

First, I need a helper:


NB. creates and documents a function
NB. could be improved to split out example
NB. or automatically assert on the example
func=: 3 : 0
(0!:0 > {: LF cut (y,'_doc'))[(y,'_doc')=: 0 : 0
)

func 'ltrim'
Removes left most space, if it exists
ex: 'abc' -: ltrim ' abc'
ltrim=: }.^:(' ' = {.)
)

func 'rtrim'
Removes right most space, if it exists
ex: 'abc' -: rtrim 'abc '
rtrim=: }:^:(' ' = {:)
)

func 'itrim'
Removes consecutive inner spaces
ex:  'abc 123' -: itrim 'abc     123'
itrim=: (#~ (0='  'E.]))
)

func 'deb'
Removes leading,trailing and consecutive spaces
ex:  'abc 123' -: deb ' abc     123 '
deb=: rtrim @: ltrim @: itrim
)


You can then do things like:

   deb_doc

Removes leading,trailing and consecutive spaces

ex: 'abc 123' -: deb ' abc 123 '

deb=: rtrim @: ltrim @: itrim



It would be neat to also be able to have all the examples automatically
assert, but I'm not sure how to do that without sinking another few hours
(probably) into it



On Tue, Jul 15, 2014 at 11:33 AM, Tracy Harms <[email protected]> wrote:

> Linda,
>
> There is a similarity that allows J's verb trains and graphic modifiers to
> be compared to silent and spoken aspects of phrasing in natural languages.
> I doubt we can rely on that similarity to much advantage.
>
> In J, when a verb is created tacitly from a combination of more than one
> component verb, the relationship between the arguments and results of its
> components is of particular interest. The "flow" among component verbs is
> emphasized by J, being one of the few things that gets written down when
> writing J.
>
> We can write down a relationship among verbs by arranging them in a train,
> or we can write down a relationship between verbs by making them arguments
> to modifiers. Yes, J emphasizes forks and hooks by making them particularly
> easy to write, which is done by making the conjoining meta-function
> invisible (i.e. unwritten). But verb trains are not wholly unlike
> conjunctions. They are better thought of as kinds of conjunctions.
>
> In writing tacit J we have choices as to how we put verbs together, but
> that's what we're doing whether we use trains or not as the means. Trains
> are handy for many things but they are not optimal for all things. J has a
> rich collection of additional operators for "routing," with Under serving
> as a fine representative.
>
> In my experience defining tacit verbs is largely about arranging the
> component verbs, and much of this is a matter of selecting their internal
> arrangement. Despite the fact that the J programming language is biased
> toward forks, it's up to each author to choose among all the options when
> phrasing.
>
> --
> T
> ----------------------------------------------------------------------
> 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