There are a lot of disclaimers here: this code, without context, is
quite useless, and typically there are easier ways to do things in J
than using objects. But here's the way I would probably do this, if I
decided that the best way to store data was to make use of values in a
locale. The key is nl, which lists all the names in the current locale.

If there's only going to be one instance of a:

b_a_ =. 'bee'
c_a_ =. 'see'
do_something&.> ".@:(,&'_a_')&.> nl_a_ ''

And if you really want a to be a new object and avoid name conflicts
(this is the more literal translation):

a =. cocreate ''
b__a =. 'bee'
c__a =. 'see'
s =. '_',(>a),'_'
do_something&.> ".@:(,&s)&.> nl__a ''

I have used something like this before. The main benefit is that a
locale, as opposed to a noun storing data, can be easily modified from
anywhere, so it allows for more extensible code.

Marshall

On Mon, Dec 03, 2012 at 06:09:56PM +0000, Alex Giannakopoulos wrote:
> On 3 December 2012 15:59, Raul Miller <rauldmil...@gmail.com> wrote:
> 
> > That said, when I want to translate J into a language other people
> > understand, Javascript is usually my first choice.
> >
> 
> Why does that not surprise me?  :-)
> 
> 
> Incidentally, and if you have nothing better to do, how would you code this
> Javascript into J?
>  a = new Object();
>  a.b = "bee";
>  a.c = "see";
>  for (var prop in a)
>       do_something(a[prop]) ;
> ----------------------------------------------------------------------
> 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