Thank you, Devon, for bringing gerunds into this discussion. An exchange here a while back reminded me of an inept COBOL programmer who created several pages of IF statements where a single "go to depending on" would have been much more efficient. After I made an (admittedly unsolicited) comment on the topic, I was reminded that J doesn't have a computed goto.
I briefly looked into the J "case." documentation and feared (perhaps incorrectly; I'll look closer) the inefficient approach was being institutionalized. When long ago I first read (Rogers?) excellent article on case statements: https://www.jsoftware.com/help/phrases/case_statements.htm I was focused only on primitive verbs, and wasn't sufficiently imaginative to think of many applications. That is probably because I come from a compiled language world where executing a source language statement, if even possible, was frowned upon as kludgey and inefficient (and dangerous, ala SQL.) But in a J interpreted world, my guess is that the gerund approach should be much preferred. > On Feb 14, 2020, at 8:47 PM, Devon McCormick <devon...@gmail.com> wrote: > > f0=. 3 : 'echo ''this''[y'"0 > f1=. 3 : 'echo ''that''[y'"0 > f2=. 3 : 'echo ''etc''[y'"0 > > f0`f1`f2 @.]"0]i.3 > this > that > etc > >> On Fri, Feb 14, 2020 at 4:58 PM PMA <armst...@eskimo.com> wrote: >> >> Ahhhhhhhhh, beautiful, thank you!!! >> >>> On 02/14/2020 04:33 PM, Julian Fondren wrote: >>> TEST =: 3 : 0 >>> for_NAME. y do. >>> select. NAME >>> case. 0 do. echo 'this' >>> case. 1 do. echo 'that' >>> case. do. echo 'etc' >>> end. >>> end. >>> ) >>> >>> as used: >>> >>> TEST i.3 >>> this >>> that >>> etc >>> >>> That's the second 'for' at >>> https://code.jsoftware.com/wiki/Vocabulary/fordot >>> >>> On 2020-02-14 15:25, PMA wrote: >>>> Hi J Gurus, >>>> >>>> Please forgive an awfully naive question. >>>> Here it is in sorta-J context -- >>>> >>>> TEST =: 3 : 0 >>>> For each item (an integer) in y >>>> do. >>>> How can I NAME the item, in order to >>>> select. NAME and then run >>>> case. 0 do. this >>>> case. 1 do. that, etc., against it? >>>> end. >>>> end. >>>> ) >>>> >>>> Thanks in advance, >>>> Pete >>>> ---------------------------------------------------------------------- >>>> 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 >> > > > -- > > Devon McCormick, CFA > > Quantitative Consultant > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm