First, let me say: wow. Using a (or the more general dont from Dan's post, which I will use and call d), we can PUT ANY J OBJECT IN A BOX. This means it can be passed around as a noun and invoked in an explicit context.
d =. (]^:(1:`(<'@.')) nest2Box)@:gTxt ]infix =: <@d '/' ┌─┐ │/│ └─┘ + (>infix) 3 4 5 12 As long as we are inside the same tacit verb where d was called, its output will be treated as a noun, despite the fact that it isn't: d@> '@&' @ ([: $ d@>) '@&' 2 ([: |. d@>) '@&' & ([: (<"0) 3 3 $ d@>) '@&' ┌─┬─┬─┐ │@│&│@│ ├─┼─┼─┤ │&│@│&│ ├─┼─┼─┤ │@│&│@│ └─┴─┴─┘ Note that this clearly shows that the output of d@> '@$' is still a list, even though it's displayed and treated as a single conjunction. Once we exit the verb into an explicit context, the parser figures out that it is dealing with a non-noun and starts treating it like one. use =: 3 : 'y 2 3 4' use@:d '+/' 9 I don't think it's possible to use the result of d in a tacit context, but I could be wrong. Of course explicit helper verbs that take boxed things and apply them to other boxed things could be used, and they could even be made polymorphic using 3!:0 . This is, of course, a bug. I can't find anywhere in the dictionary where it says a verb must return a noun, but it's assumed throughout, and explicit verbs are specifically made to throw a domain error rather than return something that's not a noun. However, it's really cool and quite possible useful--passing arbitrary J objects through verbs without the overhead of gerunds or the hassle of names is very cool. Marshall On Sat, Jan 26, 2013 at 07:58:49AM -0500, Raul Miller wrote: > On Sat, Jan 26, 2013 at 1:38 AM, Jose Mario Quintana > <[email protected]> wrote: > >> I guess this is the final proof that given J and a sufficiently > >> POWERful > >> AGENDA, you can DO anything! > > > > agenda=. ]^:(1:`(<'@.')) > > (atop=. (<'@') agenda 0) > > Or: > > a=: ]^:(1:`(<'@.'))&0@< > atop=: a '@' > type 'a' > +----+ > |verb| > +----+ > type 'atop' > +-----------+ > |conjunction| > +-----------+ > > The pun is different, of course. > > Of course, the results are not necessarily consistent: > > a&.> '@&' > +-+-+ > |@|&| > +-+-+ > a&> '@&' > @ > > But I suppose that since we already have inconsistent behavior for > displaying complex objects, maybe that's ok? > > -- > Raul > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
