Subject: Re: roman and arabic - some fun(ctions)
From: richard.levine@canrem.com (Richard Levine)
Date: Mon, 21 Aug 95 12:22:00 -0500
Organization: CRS Online  (Toronto, Ontario)

Concerning the discussion of the "arabic" and "roman" verbs,
which are like inverses, Kirk B. Iverson  kbi@io.org
kbi@acm.org CIS:74361,3602 writes:

>>>
I think you've come across an interesting area of J -- the
ability to define verbs with their inverses.
>>>

and further:

>>>
Finally, if you have any two verbs which convert to and from
a different number representation, they can be combined
together in this manner to easily extend other J verbs to
them ...
>>>

For me Kirk solved a difficulty which has been bothering me
from the times of editing the Toronto Toolkit of APL
functions, namely, how to name inverses.  Now with the power
of J, a suitable naming convention suggests itself.  Re: the
importance of names, some programmers are not so interested
in this, but I have found the book of Henry Ledgard and John
Tauer, "Programming Practice" to be invaluable in
heightening my awareness of this subject.  (The basic idea
is that accurate names for everything in a program are
important.)

Kirk's message suggested to me the following improvement
which considerably cleared up my difficulties, proving once
again the value of discussion in comp.lang.apl.

1.  The verbs are prefaced with "from" and "to"

fromroman 'vi'
6

toroman 6
vi

2.  To conform to popular practice, an alternative for
"toroman" could be ...

roman =. toroman

(This corresponds to common verbs such as "hex" or "octal"
where "hex 10" means "the hex value of 10", etc.

roman 6
vi

3.  The operator could be given an "adverb-like" name, e.g.

inroman =. &. (fromroman :. toroman)
or
inroman =. &. (fromroman :. roman)

Therefore, to do addition "IN ROMAN notation", (as KBI
points out) one can write:

'v' + inroman 'vi'
xi

(The J phrase above is defined as ...

toroman (fromroman 'v') + (fromroman 'vi')

I imagine the same principles would hold for other
languages, e.g. Frence, Russian, Icelandic, Japanese, or
others where J is used.

For example, in French, which also uses the concept of
"adverb", we could provide the following forms.  Note first
that the phrase "roman numerals" is "chiffres romains" in
French.

roman (or toroman) becomes "romain"
fromroman (the inverse) becomes "renvromain" for "renverse
romain"
inroman becomes "alaromain" (a la romain == in the roman
manner)

TOOLKIT NOTES

Looking back over the Toolkit, I realize now I in fact used
several different conventions ...

roman vs. arabic (roman numeral notation and inverse)
box vs. unbox (for vector to matrix, and inverse matrix to
vector)("unbox" is like "frombox")
julian2dmy vs dmy2julian (date translation)

I suppose that one could make use of well-known opposites,
e.g. roman numerals vs. arabic numerals.
Also some people do like the convention "this2that" and
"that2this".  The issue seems to consist of making clear the
domain and range of each verb, where these are not obvious.

J seems to provide the means for making sense of "this"
(that is, this subject).
