[I'm using parenthesis, here to separate j expressions from surrounding english text. That might be a little unfamiliar, but hopefully it's not too bad... And, on the plus side, parenthesis are valid J when their contents are valid J.]
] does replicate the right argument. And, for monadic verbs - which is what we get for (x verb\ y) contexts - the right argument is the only argument. But keep in mind that the verb (]\) has two definitions: a monadic definition and a dyadic definition. So you should expect a different result from (3 ]\ i.4) than what you get from (]\ i.4) And, this might be throwing you off: both (x verb\ y) and (verb\ y) use the monadic definition of (\)'s verb argument. However, (1 2 3) is not a verb. So that gives you a domain error right there, regardless of any right argument: 1 2 3\ |domain error To see what ] is doing, though, maybe it's better to replace it with < For example, try: 3 <\ i.6 Thanks, -- Raul On Mon, Feb 19, 2018 at 2:38 PM, Skip Cave <[email protected]> wrote: > Thanks to all the informative responses. I knew there had to be a way to > use \ for the sliding window, but > it didn't occur to me to use ] to access the right argument. > > so > > ]\1 2 3 > > 1 0 0 > > 1 2 0 > > 1 2 3 > > but > > 1 2 3\1 2 3 > > |domain error > > | 1 2 3 \1 2 3 > > I thought that ] replicated the right argument, but appaently not. > > Why does the first example work, and the second doesn't? > What exactly is the ] doing in the first example? > > Skip > > > Skip Cave > Cave Consulting LLC > > On Mon, Feb 19, 2018 at 1:09 PM, Skip Cave <[email protected]> wrote: > >> How can one create a sliding window in J? >> >> 3 sw i.6 >> >> 0 1 2 >> 1 2 3 >> 2 3 4 >> 3 4 5 >> >> 4 sw i.7 >> 0 1 2 3 >> 1 2 3 4 >> 2 3 4 5 >> 3 4 5 6 >> 4 5 6 7 >> >> What is the J code for sw? >> >> >> >> >> >> Skip Cave >> Cave Consulting LLC >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
