Avoiding the repeated name of the verb in the train

Consider a dyadic verb gdefined in terms of a binary verb f:

g=. [ f&.|: f

Is it possible to rewrite gso that the member fappears only once, but the behavior has not changed?

UPDATE: Local context

This question arose as part of my solution to this problem , which "expands" the matrix in both directions:

Original matrix

1 2 3
4 5 6
7 8 9

Extended Matrix

1 1 1 1 2 3 3 3 3
1 1 1 1 2 3 3 3 3
1 1 1 1 2 3 3 3 3
1 1 1 1 2 3 3 3 3
4 4 4 4 5 6 6 6 6
7 7 7 7 8 9 9 9 9
7 7 7 7 8 9 9 9 9
7 7 7 7 8 9 9 9 9
7 7 7 7 8 9 9 9 9

My solution was to first expand the rows of the matrix using:

f=. ([ # ,:@{.@]) , ] , [ # ,:@{:@]

And then apply the same solution under transposition to expand the columns of an already expanded row:

3 ([ f&.|: f) m

, f inline...

!

+1
2

. , (|:@f)^:(+: x) y. ( ) 0&(|:{.,],{:)~+:.

   (>: i. 3 3) (0&(|:{.,],{:)~+:) 2
1 1 1 2 3 3 3
1 1 1 2 3 3 3
1 1 1 2 3 3 3
4 4 4 5 6 6 6
7 7 7 8 9 9 9
7 7 7 8 9 9 9
7 7 7 8 9 9 9
+2

, . x f y, - x. f , . f, x f y, f , f, .

, , f, .

J, - , !

+1

Source: https://habr.com/ru/post/1681074/


All Articles