If I have to use 0!:100 instead of ". that means that the represented
string cannot be placed in parenthesis and composed with another
represented string.

In other words, that means that the string is not syntactically valid J.

The use of a J session, rather than a J expression, is valid in some
contexts (for example, the definition of a locale), but when the original
item can be validly placed inside parenthesis, I want its string
representation to also be valid inside parenthesis.

This kind of approach -- translating an item to a string with the same
syntactic properties of the original item -- makes reasoning about the item
simple than the alternative (where some items cannot be represented that
way).  It can be useful when writing some kinds of conjunctions, for
example.

-- 
Raul

On Sun, Feb 19, 2012 at 11:02 AM, Henry Rich <henryhr...@nc.rr.com> wrote:

> If you use 0!:100 rather than ". you can do it more easily:
>
>    0!:100 'copyoflist=.', 5!:5<'list_z_'
>    copyoflist
> 3 : 0
> w=.{.wcsize''
> ...
> )
>
>
> 0!:100 is multi-line ". with only side-effects, no return value.
>
> Henry Rich
>
> On 2/18/2012 3:10 PM, Raul Miller wrote:
> > In another thread, I was struggling to discuss issues which conflicted
> > with the topic.
> >
> > So... I am making a new topic:  Given a nameable entity, in J,
> > construct a list of characters that can be used in ". to recreate that
> > nameable entity.   (A nameable entity, in J, is something that can be
> > enclosed in parenthesis and still be syntactically valid.)
> >
> > This mechanism is very like the "serialization" that I use in other
> > languages, so I will call it "serialization".
> >
> > Serialization is very like J's linear representation, but not quite.
> > The problem with linear representation, is that it's not always valid
> > for ".
> >
> > Here's an example of the reason we cannot use linear representation
> > (5!:5) for serialization:
> >
> >    ".'copyoflist=.',5!:5<'list_z_'
> > |spelling error
> >
> > Or, more formally:
> >    ".'copyoflist=.(',(5!:5<'list_z_'),')'
> > |spelling error
> >
> > 5!:5 does not always generate a character sequence which is valid
> > between parenthesis, when it is presented with a name which is not a
> > noun.  Apparently, though, when given a noun, it always serializes the
> > noun.  [I do not have handy any written guarantees of this, but I also
> > have not been able to construct any counter examples.)
> >
> > So, that suggests a serialization mechanism like this:
> >
> > serializeNamedEntity=: 3 :0
> >   select. nc<y
> >     case.0 do. 5!:5<y
> >     case.  do. '(',')`:6',~5!:5<'m' [ m=. 5!:1<y
> >   end.
> > )
> >
> > And, as a test:
> >
> >   ".'example1=:',serializeNamedEntity 'serializeNamedEntity'
> >
> >   'example1' (-:&(5!:1)&<) 'serializeNamedEntity'
> > 1
> >   ". ']&example3=:',serializeNamedEntity 'example2'[ example2=: a.
> >
> >   'example3' (-:&(5!:1)&<) 'example2'
> > 1
> >
> > It's probably also good for adverbs and conjunctions (which is why I
> > had the entity specified by name, rather than by value).
> >
> > This depends on undocumented behavior of 5!:5 and of `:6, but it seems
> > reasonably robust.
> >
> > It might be worthwhile using 5!:5 directly, and testing its result and
> > falling back to the longer mechanism only when necessary.
> >
> ----------------------------------------------------------------------
> 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