<none> 
Author Message
 <none>



NB. Newsgroups: comp.lang.apl
NB. Subject: Help Beginner
NB. Date: Sunday, October 19, 1997 11:13 PM
NB.
NB. Who knows an instruction which generates the matrix
NB.   corresponding to 6!49 ?
NB. I mean 1 2 3 4 5 6, 1 2 3 4 5 7 ... Thanks.
NB.
NB. --

NB. ---- direct approach: recursive matrices


c=: dyad define
select. (x.=1)+ +:(x.=y.)    NB. OR
  case. 2   do. ,:|.>:i.y.   NB. 1-row N-col array
    case. 1;3 do. ,.>:i.y.     NB. N-row 1-col array

      end.                         NB. (see below)
      )

3 c 5   NB. works ok
NB. 6 c 49  -- dies: recursion + big matrices in memory

NB. X c Y =:  [Y .. 1]  case  X=Y
NB.
NB.           [ 1 ]
NB.           [ ..]     case  X=1
NB.           [ Y ]
NB.
NB.           [ X ]           [ X-1 ]
NB.           [ ..] , (X-1) c [ ..  ]  default
NB.           [ Y ]           [ Y-1 ]

NB. ---- indirect approach: recursive placeholders (like A.)

6!49              NB. 13`983`816
$(6!6 r 49)       NB. 44
5!|.5 r 48        NB. partition sizes
+/\5!|.5 r 48     NB. partition boundaries
{: +/\5!|.5 r 48  NB. 13`983`816

cl=: dyad define
'I M N'=. x.,y.                NB. []IO=1
select. (1=M)+ +:(N=M)         NB. OR
  case. 2   do. |.>:i.N        NB. 1-row N-col array
    case. 1;3 do. (<:I){|.>:i.N  NB. N-row 1-col array
      case. 0   do.
      R=. +/ I>S=.+/\(M-1)!|.<:M r N
      R=. (N-R),(I-R{0,S) cl (M-1),<:N-R
      end.
      )

6-(>:i.10) cl"0 1[ 3 5    NB. works fine
50-(>:i.10) cl"0 1[ 6 49  NB. as well

NB. the end



Sat, 15 Apr 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. <none>

2. <None>

3. <none>

4. <none>

5. <none>

6. <None>

7. <none>

8. <none>

9. <none>

10. <None>

11. <None>

12. <None>

 

 
Powered by phpBB® Forum Software