J provides verb names for the numbers _9 to 9 for convenience. You can use
Rank (") to make any noun into a verb. So0: ` (1"_) @. (0&<:) &> i:10 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1: is the same thing as 1"_ 0: ` (64"_) @. (0&<:) &> i:10 0 0 0 0 0 0 0 0 0 0 64 64 64 64 64 64 64 64 64 64 64 On Sun, May 9, 2010 at 6:10 AM, Ian Gorse <[email protected]> wrote: > Hi list, > > I am currently learning / experimenting with gerunds and made this > very simple snippet that returns 1 if x >= 0, or 0 otherwise > > 0: ` 1: @. (0&<:) &> i:10 > 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 > > now lets say I wanted to return 64 instead of 1 > > 0: ` 64: @. (0&<:) &> i:10 > |spelling error > | 0: ` 64: @. (0&<:) &> i:10 > | > > ok, that's because 64: is not a j verb, so how about.. > > 0: ` (2^6) @. (0&<:) &> i:10 > |domain error > | 0:`(2^6)@.(0&<:)&>i:10 > > ok, that's because (2^6) is not a function, so what about.. > > 0: ` (2:^6:) @. (0&<:) &> i:10 > 0 0 0 0 0 0 0 0 0 0 64 64 64 64 64 64 64 64 64 64 64 > > ok, that was simple enough, so lets try 33 > > 0: ` (3:+3:*2:*5:) @. (0&<:) &> i:10 > 0 0 0 0 0 0 0 0 0 0 33 33 33 33 33 33 33 33 33 33 33 > > this is starting to become ugly. > > I could easily write an explicit verb to give me the answer I am > looking for - but I am not particularly looking to make explicit verbs > thirty3=. 3 : '33' > 0: ` thirty3 @. (0&<:) &> i:10 > > I am just wondering if I am missing something obvious? > > Thanks > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
