Can't get on this trains ...
Author Message
Can't get on this trains ...

Randy MacDonald writes on Saturday, July 29:

Quote:
> From programming in J (Kenneth E. Iverson ISI 1992)

> definition of a conjunction hcb; the expression f hcb g y applies
> f to the head of y and catenates the result with the result of g
> applied to the rest (behead) of y. For example:
>    ! hcb (*/)5 1 2 3 4 5
> 120 120
>  ... but when I use the parsing rules, I get a different beast:

>         v ((cv)`(cv)`(cv)\) v
>         v ((cv) (cv) (cv) ) v
>         v ( a    a    a   ) v
>         (((v a) a) a) v

> What am I missing?

As explained in "Programming in J" in the paragraph immediately
following the quoted passage (page 33), hcb is of the form
a c a c a a which, because such a train groups to the left, is
equivalent to ((a c a) c a) a.  The grouping would also be
apparent in the boxed or the tree display for hcb.

f hcb g

The trains c v c and c c v added since Programming in J was
published in 1992, make possible a simpler defn of hcb, as the
translator demonstrates:

hcr

In this the linear display, the heuristics for parenthesization
can be improved, as I myself would have put in the redundant

are helpful in elucidating the structure of the defn.  Thus:

5!:2 <'hcr'
+---------+-+---------+
|+--+-+--+|,|+--+-+--+|

|+--+-+--+| |+--+-+--+|
+---------+-+---------+
5!:4 <'hcr'
+- [.

|   +- {.
--+- ,
|   +- ].

+- }.

Sun, 18 Jan 1998 03:00:00 GMT

 Page 1 of 1 [ 1 post ]

Relevant Pages