Here's a different approach:

paras=:(0;(0 10#:10*".;._2]0 :0);a.=LF)&;:
 1.1 0   NB. state 0 - start
 1   2   NB. state 1 - body of paragraph
 1   0.2 NB. state 2 -- got one newline
)

paras 0 :0
This is the
first paragraph.

And the second
)

+-----------------------------+---------------+
|This is the first paragraph. |And the second |
+-----------------------------+---------------+

Note that this leaves the newline characters in the bodys of the
paragraphs (including a second newline for paragraphs which have
a second, but not including any later newlines).

This may or may not be useful.  (And, note that variations can be
built on this theme -- for example, the second newline can always
be eliminated, or all such newlines can be included, though these
are slightly more complicated.  On the other hand replacing newlines
with spaces is something that should happen outside of ;:)

Whether you consider this easy is, of course, a different issue (these
kinds of definitions involve more typing, for instance).

--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to