Here's a more concise implementation of 'rank for argument
list monads':
rnk=:2 :0
assert.1=#$y
assert. n =&# y
cellsz=. ([EMAIL PROTECTED]&> y) ([ <. 0 >. ] + [ * 0 > ]) (#y){.n
frames=. (-cellsz) (}. $)&.> y
prefix=. (] {::~ [: (i. >./) #&>) frames
assert. frames -: (#&>frames) {.&.> <prefix
cindex=. > ,.&.>/ (,@$"1 0~ }.&[EMAIL PROTECTED]@$)&.> i.&.> frames
prefix $ u"1 cindex {&>"1 cellsz 4 :',<"x y'&.> y
)
Intermediate result name notes:
cellsz -- the rank of cells in the argument list's nouns
frames -- the frame dimensions in this argument list
prefix -- the result frame (shape prefix)
cindex -- with a row for each verb application, index cells from
argument list
Example use:
(0&{:: + 1&{:: * 2&{::) rnk 1 0 1 <"1 i. 3 3
18 22 26
24 29 34
30 36 42
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm