Raul Miller-4 wrote:
>
>
> insv=: [:>[: 1 0&|:@#&.>/ 1 ; <@] ,~ ((1 j. (= i.))&.> $)
>
> Here is a version which uses an arbitrary fill number:
> insf=: {:@[ + }:@[ insv ] - {:@[
>
> Example use:
> 2 3 9 insf >:i.5 5
>
insf works only partially correctly:
2 3 9 insf >:i.5 5
1 6 11 16 9 21
2 7 12 17 9 22
3 8 13 18 9 23
9 9 9 9 9 9
4 9 14 19 9 24
5 10 15 20 9 25
0 0 9 insf >:i.5 5
1 9 6 11 16 21
9 9 9 9 9 9
2 9 7 12 17 22
3 9 8 13 18 23
4 9 9 14 19 24
5 9 10 15 20 25
In contradistinction, insert does it:
(0 0 insert 0) >:i.5 5
0 0 0 0 0 0
0 1 2 3 4 5
0 6 7 8 9 10
0 11 12 13 14 15
0 16 17 18 19 20
0 21 22 23 24 25
(5 5 insert 0) >:i.5 5
1 2 3 4 5 0
6 7 8 9 10 0
11 12 13 14 15 0
16 17 18 19 20 0
21 22 23 24 25 0
0 0 0 0 0 0
Furthermore, after replacing F into insert, we get:
ins =: 2 : 'y&,(|:@)(^:2)&.(x&|.)'
That's short all right, but, again, I don't think it can be made tacit.
--
View this message in context:
http://www.nabble.com/Higher-order-functions-in-J%2C-or%2C-programming-without-verbs.-tp21441404s24193p21497006.html
Sent from the J Programming mailing list archive at Nabble.com.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm