On Thu, Apr 8, 2010 at 10:19 AM, L.Tomei <[email protected]> wrote:
>
> I'm looking for a verb to flatten every J data to a single character string,
> with the same display.
> I've found that the verb flatten (defined in format.ijs) does not work
> properly with some arguments (when rank of y is >2); example:
>
> load 'format'
> ]myarr=: ,:('Hello',LF,'World'),:'bye'
> Hello
> World
> bye
> flatten myarr
> Hello World
> bye
>
> I think this happens because there is a boxing inside the verb, where LF is
> lost.
There is no boxing.
My first impression was that you were objecting
to the presence of the LF which you had included
in the original data. However, on re-reading I
have decided that you are objecting that ; does
not do what you want:
i. 2 2
0 1
2 3
;i.2 2
0 1 2 3
You apparently want, for that particular example:
}:;(":i.2 2),.LF
Or, for the general case, one of these:
linfmtE=:3 :0
t=:":y
for_n.}.i.#$y do.
t=:;"2 ,&LF"1 t
end.
(-.#$y)}.t
)
linfmtT=: -...@#@$ }. ;"2@:(,&LF"1)^:(_1 + #...@$)@":
FYI,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm