Actually, 3 {.\ 1 2 3 4 5 worked: {. 1 2 3 gives you 1 {. 2 3 4 gives you 2 {. 3 4 5 gives you 3
So... the result of using {. with a sliding window is the first element from each of those window instances. Thanks, -- Raul On Mon, Feb 19, 2018 at 3:24 PM, Skip Cave <s...@caveconsulting.com> wrote: > Raul said: > > However, (1 2 3) is not a verb. So that gives you a domain error right > there, regardless of any right argument: > > Doh! NOW i get it. ] is the verb and 3 is the noun. > > So any verb should work... > > 3<\1 2 3 4 5 > > ┌─────┬─────┬─────┐ > > │ 1 2 3 │ 2 3 4 │ 3 4 5 │ > > └─────┴─────┴─────┘ > > > 3{.\1 2 3 4 5 > > 1 2 3 > > Hmmm.. why didn't that last one work? Wait! I think I know... > > 3{."1\1 2 3 4 5 > > 1 2 3 > > Nope, > > 3{."0\1 2 3 4 5 > > 1 2 3 > > 2 3 4 > > 3 4 5 > > Yes! I'm not exactly sure why, but that's another way to achieve the same > result that I was originally trying for. > > Skip > > > > > > > Skip Cave > Cave Consulting LLC > > On Mon, Feb 19, 2018 at 1:47 PM, Raul Miller <rauldmil...@gmail.com> wrote: > >> [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 <s...@caveconsulting.com> >> 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 <s...@caveconsulting.com> >> 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 >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm