Yes, that bug is truly a pun-ishment. -Dan
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Raul Miller Sent: Sunday, November 03, 2013 10:23 AM To: Programming forum Subject: Re: [Jprogramming] making a 'first' adverb tacit And, of course, with these definitions: strip |domain error I'm not sure I can take this much puns. -- Raul On Sun, Nov 3, 2013 at 10:10 AM, Dan Bron <[email protected]> wrote: > Pascal Jasmin wrote: > > (`'') is an anonymous tacit adverb that will produce the atomic > > rep of its verb argument that seems pretty cool, but I haven't been > > able to grasp a use for it yet. > > Advanced adverbial programming -- past the outskirts of (`:6), beyond > the hinterlands of the sneaky agenda trick -- often involves > transforming atomic representations. That is, writing verbs which > take a.r.s as input and produce different, related a.r.s as output. > The adverb (`'') is a short, simple way to convert input into its > atomic representation, and so prepare it for further transformation. > > Think of it as anesthesia for verbs: like people, verbs prefer to be > unconscious during surgery, so (`'') puts them under the beginning, > and > (`:6) wakes them up at the end, transformed. > > -Dan > > PS: "But wait,", you remark, "adverbs can take nouns for input as > well as verbs. So what implications does (`'') have for them?". Good > question. It really depends on what your adverb is doing. The first > thing to note is that (`'') is mostly an identity function for nouns: > x`'' is identical to x, except where x is scalar, in which case it's > identical to ,x (viz, x,'' ). > So, in a sense, (`'') is a normalizing preprocessor: it ensures all > inputs are nouns (verbs are converted to nouns, and nouns are left alone, mostly). > > > So, if your only requirement is that the inputs to the core of your > adverb are nouns, (`'') is perfect. However, since we're discussing > the method of adverbial programming which transforms atomic > representations, we require a deeper normalization than that. Recall > that (`'') converts verbs to nouns, but not any old nouns; no, verb inputs are converted to a special type of > noun, in a restricted domain: atomic representations. So, to really put > verb and noun inputs on equal footing, to achieve true homogenization, > so that our core transformation doesn't have to care whether the > original input was a verb or a noun (unless it wants to), we need to > do something extra. > We need to force nouns into the same restricted domain as verbs: to > nondestructively convert a noun to its own atomic representation. > > One quick, cute (and arguably elegantly symmetric) method to do that > is > simple: just convert all nouns to verbs before converting all verbs to > nouns! But ... doesn't that beg the question? Surely if we could > distinguish noun from verb input, we wouldn't need to convert nouns to > verbs in the first place? Or, conversely, if we try to coerce nouns to > verbs without knowing what kind of input we have, won't that have > unintended consequences for verbal input? > > Well, kinda. What we'd really like is some kind of identity adverb. > Sort of like (`''), which converts verbs to nouns and (mostly) leaves > nouns alone. > Only we want its dual: we wish to convert nouns to verbs, and leave > verbs > (mostly) alone. Sound familiar? > > Convert noun to verb: N"_ . Leave verb (mostly) alone: f"_ . Tada! > > So, how's this for a homogenizing utility adverb? ("_) (`'') . > Pretty sweet! First, all nouns are converted to verbs (N"_) and verbs > are mostly left alone (f"_ will never change the results of f applied > to arguments, though it may change other verbs derived from f ). > Second, all verbs (now > meaning: all input) are converted to nouns, specifically atomic > representations. Voila! We have evolved from raw chloroform to > balanced anesthesia. > > Of course, there are some artifacts left behind: the needle in the > vein, or the mask over the face, which may interfere with our > operation. But, since the patient is safely knocked out, we can > remove these extranea without fear; he'll sleep until we're ready to > wake him. In this case, the obstructive mask is ("_) : our verb (or > noun) wasn't wearing that when he walked in. Let's take it off, and > give ourselves complete access to the patient. > > knockOut =: ("_) (`'') > strip =: ((<":noun)`) (({.@>@{:)`) (@.(0; 1 2)) > prep =: knockOut strip > > ar =: 1 : '5!:1<,''u''' > (+ ar ) -: + prep NB. a.r. of plus > 1 > (+/ ar) -: +/ prep NB. a.r. of sum > 1 > (3 ar ) -: 3 prep NB. a.r. of three > 1 > (a: ar) -: a: prep NB. a.r. of ace > 1 > > Pretty neat. A tacit adverb which produces the unadulterated atomic > representation of its input, with a total domain (i.e. all nouns and > all > verbs: everything an adverb could possibly take as an argument). > > However, we lost a little something of the elegance of 'knockOut' by > introducing 'strip' (which I considered naming 'stripNude', but since > the NSA is watching, I thought it prudent to be more prudish). As > compensation, 'strip' serves both as a self-documenting example and a > utility. That is, it demonstrates how to manipulate atomic > representations to modify code, while also producing exactly the a.r.s > intended to be so manipulated. And, as a utility, it can save you a > step. Rather than use the output of 'strip', you could layer your own > transformation on top of the one it applies, and then execute the > result. > > For example: > > stripNtriple =: ((<":noun)`) (((<3;~":noun),#`'',{.@>@{:)`) > (@.(0; 1 2)) > +/ knockOut stripNtriple 1 2 3 > 6 6 6 > 6 knockOut stripNtriple > 6 6 6 > > Anyway, that's the "why" and "how" of (`''). For more examples of the > "what", try searching the Forum archives or the Wiki for instances of > (`'') or (''`) . > > PPS: Exercise for the very ambitious reader: define a tacit adverb > opTheat (operating theatre), which, given a verb (the surgeon), > derives another tacit adverb, such that > > surgeon OpTheat > ((<":0)`) (surgeon`) (@.(0; 1 2)) > > The objective is to be able to provide an convenient utility / > interface for adverbial programmers, so that their responsibility is > only to write the core a.r.-transforming function (i.e. perform the > surgery), and not always have to prepare the patient and the operating > theatre themselves. > > Note that excessive quoting will somewhat defeat the purpose of the > exercise (defining the adverb _tacitly_; it's easy to do explicitly, > exactly because that's just quoted code). > > > ---------------------------------------------------------------------- > 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
