On Fri, 04 Dec 2009, Alex Rufon wrote:
> I was working on restoreXLS2JDB and I realized that I used a verb not in any
> of the JAL or System:
>
> mat2boxedlist=: 3 : 0
> dat=. <"1 |: ,each y
> opn=. > each dat
> emp=. isempty &> opn
> num=. bx emp < 2 ~: 3!:0 &> opn
> dat=. (, each num { opn) num } dat
> ndx=. (i.#dat) -. num
> (blankout each ndx { dat) ndx } dat
> )
> blankout=: 3 : 'boxEMPTY (bx y = <,'' '') } y'
> boxitems=: <"_1 ^: (0: = L.)
> boxedlist2mat=: [: |: boxitems &>
>
> For example, you have a data that looks like this:
> [data=. |:><every each 1 2 3 4 5;'abcde';6 7 8 9 10
> +-+-+--+
> |1|a|6 |
> +-+-+--+
> |2|b|7 |
> +-+-+--+
> |3|c|8 |
> +-+-+--+
> |4|d|9 |
> +-+-+--+
> |5|e|10|
> +-+-+--+
>
> mat2boxed will convert this to a list while respecting the datatype like so:
> mat2boxedlist data
> +---------+-----------+----------+
> |1 2 3 4 5|+-+-+-+-+-+|6 7 8 9 10|
> | ||a|b|c|d|e|| |
> | |+-+-+-+-+-+| |
> +---------+-----------+----------+
>
> Running boxedlist2mat will do the reverse:
> boxedlist2mat mat2boxedlist data
> +-+-+--+
> |1|a|6 |
> +-+-+--+
> |2|b|7 |
> +-+-+--+
> |3|c|8 |
> +-+-+--+
> |4|d|9 |
> +-+-+--+
> |5|e|10|
> +-+-+--+
>
> My question now is if we already have verbs that does the exact same thing in
> JAL or the SYSTEM libraries? I've been searching and not getting anywhere.
>
> Thanks.
>
> r/Alex
>
> -----Original Message-----
> [---=| TOFU protection by t-prot: 118 lines snipped |=---]
I you change conversion rule regarding character data, there are afi
and ifa verbs both described in Roger Hui's essay on inverted table in
jwiki.
--
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