On Tue, Jan 5, 2016 at 6:21 AM, Linda A Alvord <[email protected]> wrote:
> Here's code I'm trying to understand. Is there some path to take to make > this easier? > > i=:([: i. [: # [)`([: ;/ [)`]} > It's a lot easier to understand a piece of code once you know what it does, so knowing where it came from would help. But in any case, it's a gerund being passed to } and you're using it as a dyad, so... http://www.jsoftware.com/jwiki/Vocabulary/curlyrt (scroll down to 'amend') The comments toward the bottom say that gerund x v0`v1`v2} y executes as (x v0 y) (x v1 y)} (x v2 y) v0 =: [: i. [: # [ v1 =: [: ;/ [ v2 =: ] So that simplifies to: (i. # x) (;/ x) } y So basically, x is a list of 2d coordinates, and the numbers i.#x are placed in those coordinates in y. It's easier to see if you use _ instead of 0 for G: G =: 5 5 $ _ S=: 4 4 , 0 2, 3 4, 2 2, 0 0,: 0 3 i=:([: i. [: # [)`([: ;/ [)`]} S i G 4 _ 1 5 _ _ _ _ _ _ _ _ 3 _ _ _ _ _ _ 2 _ _ _ _ 0 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
