David Ward Lambert asked: > I have not yet successfully traced the substitutions of the > power operator, but why do you need it?
Because ]^:(1:`(<'@.')) is a verb and @. is a conjunction. Conjunctions are limited because their arguments are forever fixed. They can't be changed at runtime. We can a limited form of reusability from @. by using by using verbal right arguments, but due to limitations in the implementation of @. , even that limited dynamism is hamstrung (and of course there's no way to change the left argument at all). In contrast, the verb ]^:(1:`(<'@.')) can be re-used with multiple distinct left arguments, and furthermore allows the right argument to be integer vectors, which permit multi-application (along the lines of `:0), and, even more impressive, boxed vectors, which allow arbitrary composition of the elements of the gerund (with full nesting!). In other words, in addition to the standard advantages of a verb over a conjunction (dynamic arguments, flexibility derived from rank and other modifiers, etc), ]^:(1:`(<'@.')) has the overwhelming advantage of being able to execute _arbitrary noun phrases_. As a simple example of that, I used it to reimplement ". (aka the J language). But, with a little creativity, you could use it to interpret any number of little languages. The utility of embedded "domain specific languages", or DSLs, is well-known in industry. If the difference still isn't clear, check out the verb "dont", and try to reimplement it without the using ]^:(1:`(<'@.')) or something equally sneaky. With all that said ... I was mostly being cute :) Showing off stupid J tricks. -Dan PS: The need for these kinds of sneaky tricks would be significantly reduced if the limitations on @. were lifted. In particular, if in [email protected] g were permitted to return vector arguments (integer and boxed). The conjunction still wouldn't be as reusable as ]^:(1:`(<'@.')) , because its right argument can't change, but it would be a big step forward. Similar sentiments apply to the limitations on noun~ . Currently, using ~ to evoke a string requires that string to represent a simple name, instead of an arbitrary J sentence. For example: avg =: +/ % # 'avg'~ 1 2 3 works, cutting out the (unnecessary) middle man: '+/ % #'~ 1 2 3 |ill-formed name | '+/ % #'~1 2 3 fails. There's no good rationale for this, and implementing a ~ workalike which respects anonymous sentences requires some serious contortions. For example, here's a quote from the script I referenced yesterday, "anonymous evoke" [1]: anon_evoke =. (("_) (`'') (<@gn`)) (`(<gn 0)) (`:6) ('@.' ; (,&<&gn nest2Box)@:gTxt`) (`:6) (@.1 0 2) Which, ironically, is even more convoluted because of the earlier-mentioned limitations of @. ! [Before anyone suggests '+/ % #' 128!:2 ] 1 2 3 or ".'(+/ % #)', ": 1 2 3 note that the reason ~ is provided in addition to "., and the reason anon_evoke was developed, is because both are adverbs, and so can produce _any part of speech_. This is not true of the verbs 128!:2 or ". , which by definition must produce nouns. For example: un =. '&.:' cd =. +/ 'un'~ *: NB. Cartesian distance can't be emulated with 128!:2 etc.] [1] Anonymous evoke http://www.jsoftware.com/svn/DanBron/trunk/environment/anonymous_evoke2.ijs ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
