See the documentation for Index Of i. http://www.jsoftware.com/docs/help701/dictionary/didot.htm
1 2 3 4 i. 3 _3 NB. 1 2 3 4 index of 3 is 2; _3 not found 2 4 --Kip Murray Sent from my iPad > On Nov 5, 2013, at 8:18 AM, Joe Bogner <[email protected]> wrote: > > I'm experimenting with Agenda and building a verb to return the index. > > My case verb generally does what I'd like, but I was stumped on how to > rework it so that it stops on the first match to work more like a > traditional case statement. > > If the conditions were mutually exclusive then I could use a + between > them - each would still process though. Since they aren't, I opted for > the largest of the matching index. Is there a clean way to say the > first non-zero or zero if no others match? What would be the idomatic > way to handle it? > > Also, ideally it wouldn't process the next statement if it finds a match. > > c0=:smoutput bind 'default' > c1=:smoutput bind 'only one' > c2=:smoutput bind 'two' > c3=:smoutput bind 'sum >= than 10' > c4=:smoutput bind 'sum >= than 100' > case=:(1*(1 = #)) >. (2*(2 = #)) >. (3*(10 >:~ +/)) >. (4*(100 >:~ +/)) > dispatch=:(c0 ` c1 ` c2 ` c3 `c4) @. case > > dispatch 1 > only one > > dispatch 2 > only one > > dispatch 1 2 > two > > dispatch 2 8 > sum >= than 10 > > dispatch 2 3 5 > sum >= than 10 > > dispatch 2 3 5 100 > sum >= than 100 > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
