I see the removal of possible double-quotes as "data qualification." I like
to segregate such things from the main logic. This phrasing is one way to
move it to the side:
quoteIfSp=: (] (],[,]) '"' #~ ' ' e. ])@ ( -.&'"' )
I originally phrased the conclusion as a hook, then decided it's easier to
read as a fork. At that point I realized that I don't like shifting my
interpretation of ] by context, and propose this one in its place:
quoteIfSp=: (('"' #~ ' ' e. ]) ([,],[) ])@ ( -.&'"' )
That strays from a couple conventions, but I like how it emphasizes what I
see as the main structure. ([,],[)
But this encourages me to make that structure more prominent by cloaking the
other aspects in names. This is where that takes me. (I happen to depart
from camelCase in the process.)
make_valid =: -.&'"'
maybe_a_quote=: '"' #~ ' ' e. ]
quote_if_sp =: maybe_a_quote ([,],[) make_valid
In this form I personally find it as approachable as an explicit definition.
None of what I've written here applies to Christopher's original question,
in my opinion, but comparison of tacit and explicit techniques can be
interesting in its own right.
On the matter of working around the special status of the 6 system-sensitive
names, I wholly agree that there is no benefit in doing so for production
work.
--Tracy
On Tue, Sep 27, 2011 at 3:25 PM, Devon McCormick <[email protected]> wrote:
> The issue of working around the special status of the names "m", "n", "u",
> "v", "x", and "y" seems like a long walk off a short pier and the solution
> seems just as simple:
>
> Don't do that.
>
> They are only six names - many languages have hundreds of reserved words -
> and they are pretty crummy names as well. They're fine in their simple
> roles as generic place-holders but I don't understand the desire to use bad
> names: either use no names at all or use meaningful ones. At least pick
> names with more than one letter - the time you save when you have to do a
> search will be well worth it.
>
> On the related issue of tacit versus explicit, I, too find that long, tacit
> expressions are hard to read though I'm slowly improving my ability to do
> so. Compare this simple explicit version of a verb
>
> quoteIfSp=: 3 : 0
> ifsp=. '"'#~' ' e. y
> flnm=. ifsp,(y-.'"'),ifsp
> )
>
> (where the final assignment is purely documentary) to its tacit equivalent
>
> (] ([,[,~ '"' -.~ ])~ '"' #~ ' ' e. ])
>
> Perhaps a compromise would be useful:
>
> quoteIfSp=: ] ([,[,~ '"' -.~ ])~ '"' #~ ' '&e. NB.* quoteIfSp: surround
> name with '"'s if embedded spaces (stupid MS!).
>
> In any case, with locales and local assignment, I don't see namespace
> clutter as being much of a problem.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm