On Fri, Aug 21, 2009 at 4:30 PM, Dan Bron<[email protected]> wrote:
> ae =: + 1 : (0 : 0 -. 10{a.)
> ((((((("_)(`''))(<@(
I believe (("_)(`'')) could be replaced by ("_) without ill effect.
I stopped reading shortly after this point, because I was getting lost.
It seems to me that the overall structure of this purely tacit form
relies on two things:
First, you need some mechanism for taking a noun and converting it to
an atomic representation of a noun. This could be handled explicitly,
using
1 :'5!:1<''u'''
but a purely mechanism can also be accomplished.
Next, you construct a gerund representing a verb/noun pattern, which
will then be evaluated as a train using `:6 or @. I think this is
undocumented behavior -- and the design of such expressions exactly
matches the design of explicit expressions -- so in my mind this
approach is inferior to explicit evaluation. Nevertheless this
allows arbitrary computation to take place in "purely" tacit adverbs,
and mechanisms using this approach can be an interesting thought
experiment.
With this in mind, here's a "purely tacit" adverb which will
quote nouns for use in gerunds:
q=:("_)((<;:'0 a')`([:<(,'0'),&<])`)(@.1 2 0)
And, here's a demonstration of its use.
(1 q)`+`(1 q)`:6
2
Or
(1 q)`[email protected] 1 0
2
With that out of the way, here's an example of how ae's
core mechanism:
mean=: +/ % #
(<'mean')q`(<'@.')`(0 q)`:6
+/ % #
With the tools we have, we can write a tacit adverb
which uses a verb to process a noun like this:
q(VERB`)(`:6)
Or, specifically:
box=: q(<`)(`:6)
'mean' box
+----+
|mean|
+----+
Thus:
ae2=: box q (`(<'@.'))(`(0 q))(`:6)
'mean' ae2
+/ % #
Or, if we want to eliminate names from the definition:
ae3=:+1 :(0 :0-.LF)
("_)((<;:'0 a')`([:<(,'0'),&<])`)(@.1 2 0)
(<`)(`:6)
("_)((<;:'0 a')`([:<(,'0'),&<])`)(@.1 2 0)
(`(<'@.'))
(`(<'0';&,0))
(`:6)
)
'mean' ae3
+/ % #
Now... this does not do everything ae does --
'+/ % #' ae 1 2 3
I get a domain error when I use my ae2 or ae3 on expressions like this.
Looking closer, I should have been parsing the original string with ;:
and, instead of using a constant 0, I should have been using i.# on the
parsed string. For this kind of work, it would be handy to have a verb
which does the same data manipulation as q
Q=: (,'0') <@,&< ]
99 q -: Q 99
1
ae4=: (q(Q@;:`))(`:6)((Q ,'@.'; q...@i.@#)`)(`:6)(`:6)
'+/%#' ae4
+/ % #
'+/%#' ae4 1 2 3
2
Eliminating the names from this last definition is left as an exercise
for the reader.
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm