Why can't I use x. with ` (gerund) in an explicit adverb? 
Author Message
 Why can't I use x. with ` (gerund) in an explicit adverb?

I am trying to create an adverb 'applytoselected' which
will appear with the syntax

x u applytoselected y

and will apply u to the elements of y selected by > {. x,
giving > {: x as the left argument to u each time (x is
a 2-element boxed vector with the first element controlling
section from y and the second element being the args to u).

After an hour or two with the parse table I was inspired to
try an explicit-definition adverb, so I typed:


Question 1 is, is there a better way to achieve my purpose?

Anyway, J replied:

3domain error

After experimentation I boiled it down to this:

   as =. 11 : '(x.`]) }'
3domain error

but:

   as =. 11 : '(x.&]) }'

no domain error.  So ` has a different domain from &.  Who knew?
Question 2 is, what is going on?

Seeing this I think I'll try to break my adverb into
two parts and code the tie implicitly.  The code generated for


is pretty clever.

Question 3:  The parse table shows the production

N0 A1     verb     x (N0 A1) y

So the pair

    5 ]:

should be a verb, right?  (I know it says ]: yields its
left argument, but I would have thought it would be made
into a constant verb so that the parse table would be satisfied).

But when I type

    (5 ]:) b. 0
0

I see that (N0 A1) has produced a noun.  What gives?

Henry Rich



Wed, 14 Oct 1998 03:00:00 GMT  
 Why can't I use x. with ` (gerund) in an explicit adverb?


Quote:
>After experimentation I boiled it down to this:

>   as =. 11 : '(x.`]) }'
>3domain error

>but:

>   as =. 11 : '(x.&]) }'

>no domain error.  So ` has a different domain from &.  Who knew?
>Question 2 is, what is going on?

After some more work it looks to me that x. in the adverb definition
is assumed by the interpreter to be a verb (even though an adverb
can just as well apply to a noun), and so generates a domain error
when used with ` which expects a noun left argument.

I am now trying to design an adverb that resembles } in that
it takes a gerund as the left argument, breaks it into pieces,
and uses the pieces in various ways.  So I need parts that look
like:

select =. 11 : '(1 { x.) `: 6'

(extract the second element of the gerund and evoke it)

but this fails with the aforementioned domain error, whether I use
11 :  or 1 : .  I was planning to use the gerund to pass multiple
verbs into my adverb, but now I'm stymied and I can't see an
alternative solution.  Can any of the experts provide succor?

Henry Rich



Fri, 16 Oct 1998 03:00:00 GMT  
 Why can't I use x. with ` (gerund) in an explicit adverb?

....
:
: I am now trying to design an adverb that resembles } in that
: it takes a gerund as the left argument, breaks it into pieces,
: and uses the pieces in various ways.  So I need parts that look
: like:
:
: select =. 11 : '(1 { x.) `: 6'
:
: (extract the second element of the gerund and evoke it)
:
: but this fails with the aforementioned domain error, whether I use
: 11 :  or 1 : .  I was planning to use the gerund to pass multiple
: verbs into my adverb, but now I'm stymied and I can't see an
: alternative solution.  Can any of the experts provide succor?
:
: Henry Rich

I'm not sure I understand, but does this help?

   sel=.1 : '(1&{ m.)/.'
   +`-`% sel
+---+--+
|+-+|/.|
||-||  |
|+-+|  |
+---+--+
   +`-`% sel 9
_9

The m. is new in J3 I think.
  Cliff

--
Clifford A. Reiter
Mathematics Department, Lafayette College
Easton, PA 18042 USA,   610-250-5277



Sat, 17 Oct 1998 03:00:00 GMT  
 Why can't I use x. with ` (gerund) in an explicit adverb?

What in the world is

   m.

in J 3.01?   I don't find it in the on-line or printed vocabulary.

--

  Mathematics & Statistics Dept.            Voice:  413-545-2859 (W)
  University of Massachusetts                       413-549-1020 (H)
  Amherst, MA 01003                           Fax:  413-545-180



Sat, 17 Oct 1998 03:00:00 GMT  
 Why can't I use x. with ` (gerund) in an explicit adverb?

Quote:

> What in the world is  m.  in J 3.01?

It's part of an incompatible but worthwhile change from Release 2.
The following example appears in the Rel.2 Dictionary under
Explicit Definition ":" :


           3 ! conj *: 5
        31

x. and y. refer to the conjunction's "direct" verb arguments.
You cannot, however, explicitly refer to the resulting verb's
final arguments (3 and 5, here).  You have to use some construction

Beginners who, after all, use explicit definitions to avoid tacit ones
in first place, are likely to run into trouble here.

In J Rel 3, the roles of x. and y. have now changed.
The very same place in the Dictionary now reads:

        5. The names x. and y. denote the left and right arguments.
        In defining a conjunction it may be necessary to refer to _its_
        left and right arguments (using u. and v.) as well as to the arguments
        of the resulting function (x. and y.).  The use of m. instead of u.
        restricts the corresponding argument to being a noun, as does the use
        of n. instead of v.. For example:

           conj=. 2 : '(u. y.)+ (v. y.)'

Which is the same as above, but much more "explicit".

Obviously, you also gain the benefit that the new referents follow exactly the
use of the conventional u/v/n/m/x/y names in the Dictionary.  Mind you, it can
break old code silently.

                                                        Martin Neitzel



Sun, 18 Oct 1998 03:00:00 GMT  
 Why can't I use x. with ` (gerund) in an explicit adverb?

: >
: > What in the world is  m.  in J 3.01?
:
:       5. The names x. and y. denote the left and right arguments.
:       In defining a conjunction it may be necessary to refer to _its_
:       left and right arguments (using u. and v.) as well as to the arguments
:       of the resulting function (x. and y.).  The use of m. instead of u.
:       restricts the corresponding argument to being a noun, as does the use
:       of n. instead of v.. For example:
:
:          conj=. 2 : '(u. y.)+ (v. y.)'
:

I'm failing to understand something here: I don't see any "m." in your
example. I know that "m" generically refers to a noun in Dictionary
definitions, but is "m." generic or what?  I looked on pages 150-151
of the Dictionary where "m." and "n." are mentioned, but the paragraph
mentioning them, which concludes with "For example:" is followed by an
example that uses neither "m." nor "n.".

There is one example using "n.", on page 153, where Level is modelled.
But the only entries for "m." and "n." in the index are for page 150.

--

  Mathematics & Statistics Dept.            Voice:  413-545-2859 (W)
  University of Massachusetts                       413-549-1020 (H)
  Amherst, MA 01003                           Fax:  413-545-180



Sun, 18 Oct 1998 03:00:00 GMT  
 Why can't I use x. with ` (gerund) in an explicit adverb?

Quote:

> What in the world is  m.  in J 3.01?

And the Dictionary answered:
:
:       5. The names x. and y. denote the left and right arguments.
:       In defining a conjunction it may be necessary to refer to _its_
:       left and right arguments (using u. and v.) as well as to the arguments
:       of the resulting function (x. and y.).  The use of m. instead of u.
:       restricts the corresponding argument to being a noun, as does the use
:       of n. instead of v.. For example:
:
:          conj=. 2 : '(u. y.)+ (v. y.)'

Quote:
> I'm failing to understand something here: I don't see any "m." in your
> example. I know that "m" generically refers to a noun in Dictionary
> definitions, but is "m." generic or what?

Yes, this example just exemplifies the use of u., y., v, and y. and most
importantly it shows what refers to what kind of arguments.

No, there isn't an example for m. and n.  (Definitions shouldn't depend on
examples anyway.)  Here is one.

We define conjunction "repeat" as a simplified, silly, hand-coded ^: conjunction
so that  (-: repeat 4)  100  does the same as  ( -: ^: 4) 100.  It shall combine
a verb on the left with a noun (the counter) on the right.

repeat =. 2 : 0
        i =. n.
        result =. y.
        while. i > 0 do.
                result =. u. result
                i=.<:i
        end.
        result
)

   -: repeat 4 ] 100
6.25
   -: repeat + ] 100
100
|value error
|   i=.    n.

The use of n. instead of v. to refer to the conjunction's right parameter
makes the system to notice the error at the first reference to it.  If we had
used a v. as name, both uses would have produced results.

I must apologize for giving incorrect information in my last posting.
The parameter names u., v., m., and n. have been introduced in a
backwards-compatible fashion:

As long as they are not present in an expl. definition, x. and y. continue
to refer to the conjunction's or adverb's direct arguments (typically verbs).
Only if you use any of u., v., m., and .n, they will refer to the arguments
of the later derived verb (typically).

Thanks go to Henry Rich for pointing me to this interpretation and Roger Hui
for confirming it.

                                                        M.artin N.eitzel



Mon, 19 Oct 1998 03:00:00 GMT  
 Why can't I use x. with ` (gerund) in an explicit adverb?

Quote:



> : >
> : > What in the world is  m.  in J 3.01?
> :
> :       5. The names x. and y. denote the left and right arguments.
> :       In defining a conjunction it may be necessary to refer to _its_
> :       left and right arguments (using u. and v.) as well as to the arguments
> :       of the resulting function (x. and y.).

There are so many interesting things in J up to reading this note
I was not aware of this u. and v. stuff

I knew about x. and y. and they make life so much easier than having
to specify argument names for everything in old APL.

I can imagine that using u. and v. is going to make a difference because
that will mean I will be defining conjunctions; something I have not
done up to now.

I have been able to get by with just the low level things in J.

An occasional use of something very advanced I copy from someone else
without a clue why it works.

I recently added a translated page of J description to my wild wild west
page. I would like to get some comments on it.
http://www2.simi.is/~gosi/jlysing.html
--

http://www2.simi.is/~gosi
http://www.jsoftware.com



Tue, 20 Oct 1998 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Using CGI module with 'canned queries'

2. A handy explicit adverb in J

3. Problem with J table adverb & explicit definition

4. @U$`')-`:023/7H

5. Why doesn't Smalltalk support explicit deallocation?

6. why isn't the environment explicit ?

7. Why and how do these gerunds work?

8. It's not bad canned meat...

9. It's not bad canned meat...

10. It's not bad canned meat...

11. It's not bad canned meat...

12. `#R345J!3(,]`"2

 

 
Powered by phpBB® Forum Software