>          cond1       =:  2&|
>          Something1  =:  <:
> 
>          cond2       =:  >&100
>          Something2  =:  -:
>          Something3  =:  ]
> 
>          tni =: [EMAIL PROTECTED](cond1 (* >:)&:-. cond2)
> 

Now I tried to rewrite my code by following your suggested pattern. The
initial code is the following:

Terns is of shape 10000 x 10000
Pairs is of shape 5000 x 5000
Solos is of shape 501 x 501

Next =: 13 : '0 i.~(?+/y)>+/\y'

Generate =: 3 : 0
        Text =. terns {~ ?10000
        For i.y do.
                tern =. terns i. _3{. Text
                pair =. Pairs i. _2{. Text
                if. tern < 10000 do.
                        Text =. Text, next tern { terns
                Else.
                        If. pair < 5000 do.
                                Text =. Text, next pair { pairs
                        Else.
                                Text=. Text, next ({:text){ solos       
                        End.
                End.
)

I rewrote it like that:

n=: 10000 5000 501
argument =. (terns i. _3 {.text),(pairs i. _2{. Text),{:text

gen1=:next@((0&{){&terns)
gen2=:next@((1&{){&pairs)
gen1=:next@((2&{){&solos)

gen =: [EMAIL PROTECTED]({.I.-.=&n)

Now I should be able to generate text with
Text =: text, gen argument, but I get the length error and I don't
understand what's wrong.

Kairit Sirts


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

Reply via email to