ĵaŭ, 14 Jan 2010, Sherlock Ric skribis:
> > From: Raul Miller
> > 
> > > array =: 0 1 2 3...
> > > 4 5 6 7...
> > > 8 9 10 11...
> > >
> > > I would like to do a "line continuation" at the end of every line
> > > but have no idea how to do it.  I searched the literature for a
> > > couple hours but didn't find anything.
> > >
> > > Is this possible?
> > 
> > array=: _". (0 :0)-.LF
> >    0 1 2 3
> >    4 5 6 7
> >    8 9 10 11
> > )
> > 
> > Note that this assumes that lines are indented.
> > 
> > If that is a problem for you -- if you want newlines
> > treated as whitespace, you could instead use
> > 
> > require'strings'
> > array=: _". (LF,' ')charsub 0 :0
> 
> The short answer is that you can't do line continuations in J, but as Raul 
> has shown you can define a multiline noun and parse it. 
> Here is another parsing option, but I think I like Raul's charsub idea better.
> 
> array=: ; <@(_&".);._2 noun define
> 0 1 2 3
> 4 5 6 7
> 8 9 10 11
> )

Note that this method cannot be used inside an explicit definition
because the lone ) cannot be nested.

you may use a powerful enough text editor to reformat the c code into
something like this,

array=: 0 1 2 3
array=: array, 4 5 6 7
array=: array, 8 9 10 11 
....


-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to