I have some questions:

(*) Are you guaranteed that these lists will always be the same length?

(*) Are you guaranteed that the entries will always be in order, with no
missing values?

(*) Is it possible that your text will have the delimiter (';' in this
case) in the entries?

(*) Do you care about redundant spaces (for example preceding or following
the numbers or text)?

(*) Are you in any danger of running out of memory (or disk space or time
or whatever else) because you have so much data?

Depending on the answers to these questions, you might need a different
approach. For now, I'll assume answers for them them that makes the code
the simplest.

But what I think I would do is (a) encapsulate your manipulation logic in a
verb, (b) use {. and }. with i. instead of cut, to split your lines (that
way you are guaranteed to always split on the first occurrence of the
delimiter), and (c) not reassign the variables (because that makes
understanding and debugging slightly easier, in my opinion).

In other words, given:

ingl=:0 :0
1;English
2;Write your name
3;Options
)

sved=:0 :0
1;Svenska
2;Skriv ditt namn
3;Inställningar
)

package=:3 :0
  ';' package y
:
  (({.~ ; (}.~>:)) i.&x);._2 y
)

I think I'd do it like this:

   (package ingl),. 1}."1 package sved
┌─┬───────────────┬───────────────┐
│1│English        │Svenska        │
├─┼───────────────┼───────────────┤
│2│Write your name│Skriv ditt namn│
├─┼───────────────┼───────────────┤
│3│Options        │Inställningar │
└─┴───────────────┴───────────────┘

Of course, there are other ways also (and, depending on your answers there
might be much better ways).

Thanks,

-- 
Raul






On Fri, May 16, 2014 at 3:03 AM, Gian Medri <[email protected]> wrote:

> Hi!
>
> I have 2 or more lists of substantives. The lists must be as simple as
> possible, since they are done
>
> by a translator not familiar with computer languages.
> From the lists I want to get a boxed matrix.
> The numbers in each line of the list are only for reference purposes,
> since the lists
>
> are normally hundreds of lines. I wonder if there are a better way to
> solve the problem
>
> than in the example.
>
>
>
> cut=:' '&$: :([: -.&a: <;._2@,~)
>
> ingl=.(0 : 0)
>
> 1;English
>
> 2;Write your name
>
> 3;Options
>
> )
>
> ingl=. > ';' cut each <;._2 ingl
>
>
>
> sved=. (0 : 0)
>
> 1;Svenska
>
> 2;Skriv ditt namn
>
> 3;Inställningar
>
> )
>
> sved=.1{"1 > ';' cut each <;._2 sved
>
> ]matx=:ingl,.sved
>
>
>
> ┌─┬───────────────┬───────────────┐
>
> │1 │English                            │Svenska        │
>
> ├─┼───────────────┼───────────────┤
>
> │2 │Write your name              │Skriv ditt namn│
>
> ├─┼───────────────┼───────────────┤
>
> │3 │Options                           │Inställningar │
>
> └─┴───────────────┴───────────────┘
>
>
>
>  Thanks,
>
> Gian Medri
> ----------------------------------------------------------------------
> 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