Thanks to Hui who showed me how to "rank" operators and after pimping kfcs1
a bit I come to

kfcs1=: 3 : 0
 (i.>:{:$y) kfcs1 y
:
 t=. (([: +/"(1) 0 = ]) </. ]) 3 #.^:_1 i.3^{:$y
 t=. ((- *),: 2 + 0 = ])"(1) ; x { |.t
 c=. ({. , +/ , 0 ,: {:) y
 t 4 : 'x}y'"1 _ c 
)

   C=: 10 20 30 40 ,: 1 2 3 4

   $ kfcs1 C
81 2 4

   ({:"2</.]) 3 kfcs1 C
+-----------+-----------+-----------+-----------+
|10 20 30 40|10 20 30 40|10 20 30 40|10 20 30 40|
| 1  2  3  0| 1  2  0  4| 1  0  3  4| 0  2  3  4|
|           |           |           |           |
|10 20 30 44|10 20 33 40|10 22 30 40|11 20 30 40|
| 1  2  3  0| 1  2  0  4| 1  0  3  4| 0  2  3  4|
+-----------+-----------+-----------+-----------+


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens R.E. Boss
> Verzonden: zondag 11 april 2010 18:23
> Aan: 'Programming forum'
> Onderwerp: Re: [Jprogramming] boxes
> 
> I discovered a nice solution using the method of Jacobi, see
> http://jsoftware.com/pipermail/programming/2010-April/019081.html
> His method essentially gave the structure, the rest was amending.
> 
> kfcs1=: 3 : 0
>  (i.>:{:$y) kfcs1 y
> :
>  t=. ((-*),:2+0=])"(1) (#~ x e.~ [:+/"(1) 0=]) 3 #.^:_1 i.3^{:$y
>  c=. ({. , +/ , 0 ,: {:) y
>  t amnd c
> )
> 
> amnd=: 4 : 0
>  s=. {:$y
> ($x)$ ,((s*x) +"1 i.s) { ,y
> )
> 
> I had to introduce a verb for higher order amends.
> 
> C=: 4 3 0 ,: _4 _3 _2
> 
>     2 (kfcs -:&:([:/:~@,<"2) kfcs1) C
> 1
> 
>      (kfcs -:&:([:/:~@,<"2) kfcs1) C
> 1
> 
> 
> R.E. Boss


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

Reply via email to