xtbjh@levels.sait.edu.au (behoffski) (05/10/91)
In article <b54a1g.hvl@wang.com>, wdr@wang.com (William Ricker) writes: > > Take a look in comp.lang.apl. The new language J, by Iverson Software Inc > (yes, that Ken Iverson) has a regularized grammar modeled on Verbs,Nouns, > Adverbs/adjectives, Conjunctions -- rather than Functors, Operators, Things. > Refernces ACM SigAPL QuoteQuod a/k/a Proceedings APL'90, Iverson & Hui, > "APL\?". Interesting. You will be pleased to know that *the* first language that I ever programmed in was a version of APL running on an IBM-370. Trying to understand News postings of APL programs with ASCII translations is hard, especially since it's been about ten years since I last looked at APL. I'll try and find a copy of the APL proceedings that you referenced; in the mean time, could you post a summary of Iverson's ideas, and possibly even a summary of "Functors, Operators, Things?" > /s/ Bill Ricker wdr@wang.wang.com > "The Freedom of the Press belongs to those who own one." > *** Warning: This account is not authorized to express opinions. *** -- Brenton Hoff (behoffski) | Senior Software Engineer | My opinions are mine xtbjh@Levels.UniSA.edu.au | AWA Transponder | (and they're weird).
wdr@wang.com (William Ricker) (05/16/91)
xtbjh@levels.sait.edu.au (behoffski) writes: >In article <b54a1g.hvl@wang.com>, wdr@wang.com (William Ricker) writes: >> Take a look in comp.lang.apl. The new language J, by Iverson Software Inc >> (yes, that Ken Iverson) has a regularized grammar modeled on Verbs,Nouns, >> Adverbs/adjectives, Conjunctions -- rather than Functors, Operators, Things. >> Refernces ACM SigAPL QuoteQuod a/k/a Proceedings APL'90, Iverson & Hui, >> "APL\?". >Interesting. You will be pleased to know that *the* first language >that I ever programmed in was a version of APL running on an IBM-370. ... >I'll try and find a copy of the APL proceedings that you referenced; >in the mean time, could you post a summary of Iverson's ideas, and >possibly even a summary of "Functors, Operators, Things?" I didn't dare try, so I sent a request off to the folks at Iverson Software, Inc., and received the following reply. I hope this helps. Roger Hui is the public spokesman and primary co-author (with Ken Iverson) of Iverson Software, Inc.'s software and journal articles. (Their domain address is an artifact more of their corporate ancestry & mail routing than current ownership, if I understand aright.) To get your own copy of J, FTP watserv1.waterloo.edu USER anonymous CD languages/apl/j DIR cd pc DIR BINARY GET j_pc_30.arc QUIT (there are other j/[machine] directories ... sun3, sun4, mips, 386ix etc.; a list of which are up-to-date is in the status document in apl/j.) --- bill wdr@[wang.]wang.com >From: hui@yrloc.ipsa.reuter.com (Roger Hui) Subject: J To: xtbjh@levels.sait.edu.au Date: Thu, 16 May 91 5:39:21 GMT Cc: ljdickey@watmath.waterloo.edu, wdr@elf.wang.com, rbe@yrloc.ipsa.reuter.com J is a dialect of APL specified by Ken Iverson's "A Dictionary of J" (21 pp.). The salient characteristics are that it is shareware, runs on a variety of machines (PC, Mac, Sun Sparc, Sun 3, MIPS, SGI, Atari ST, NeXT, IBM RS 6000, ...), uses only ASCII characters 0-127, and removes anomalous constructs from existing APL (e.g. bracket-semicolon indexing, del function defn) to result in a simple and consistent syntax. It has equivalents to data, functions, and operators found in existing APLs. The dictionary describes nouns (arrays), verbs (functions), adverbs (monadic operators), and conjunctions (dyadic operators). The new terminology is readily understandable by a wider audience, and has also been helpful in suggesting concepts from natural languages which are fruitful for investigation. Words in J are spelled with one or two letters from the ASCII alphabet; 2-letter words end in a period (.) or colon (:). The spelling scheme is more mnemonic that those in other APL dialects using special characters. For example, = equal < less than > larger than =. is (local assignment) <. lesser of >. larger of =: is (global assignment) <: lesser or equal >: larger or equal Those familiar with older APLs would already know some adverbs. For example, / is an adverb, and f/ is a derived verb which inserts f between the items of its argument. Thus +/ 3 4 5 6 is 3+4+5+6 is 18 */ 3 4 5 6 is 3*4*5*6 is 360 A conjunction takes 2 arguments and (usually) results in a verb. For example, one of the cases of the conjunction " is rank, wherein f"n is a verb which applies f to cells (subarrays) of the arguments according to n. A recent query to comp.lang.apl was on multiplying a 2 3 matrix M by a 2-element vector V. This can be accomplished by M *"1 0 V , meaning multiply the rank-1 objects on the left by the rank-0 objects on the right. & is another example of a conjunction, defined as follows (f,g are verbs; m,n,x,y are nouns): m&g y is m f y g&n y is y g n f&g y is f g y x f&g y is (g x) f g y Here are some common verbs defined using & : halve =. 0.5&* square =. ^&2 sqrt =. ^&0.5 norm =. sqrt & (+/) & square As the last example indicates, J permits any verb to be used as an argument to an adverb or conjunction. A fork is a sequence of 3 verbs, and a hook one of 2 verbs: (g h) y is y g h y x (g h) y is x g h y (f g h) y is (f y) g (h y) x (f g h) y is (x f y) g (x h y) For example, (+%)/1 1 1 1 1 computes a continued fractions approximation to the golden ratio, and mean=.+/ % # computes averages. Adverbs, conjunctions, and forks and hooks make possible a style of programming called tacit definition, so-called because verbs defined in this way makes no explicit reference to its arguments. Other authors call this functional programming or adverbial programming. See "Tacit Definition" by Hui/Iverson/McDonnell, to appear in APL91. In natural languages, a gerund is a verbal forms that can be used as a noun, as "programming" in "programming is an art". The ` (accent) conjunction converts verb arguments into their atomic representations. Gerunds are arrays of such atomic representations. Since gerunds are nouns, they can be manipulated by verbs, thus making verbs "first class objects". The conjunction `: derives a variety of useful verbs from gerunds, including if-then-else, do-until, case, and recursion. See "Gerunds and Representations", by Bernecky and Hui, to appear in APL91. The following publications are also relevant: K.E. Iverson, "A Dictionary of APL", APL Quote-Quad, Volume 18, Number 1, September 1987. Precursor to J. Hui/Iverson/McDonnell/Whitney, "APL\?", APL90 Conference Proceedings, APL Quote-Quad, Volumn 20, Number 4, July 1990. Introduced J; discussed some of the reasoning behind the design. Iverson, "Tangible Math and the ISI Dictionary of J", Iverson Software Inc. March 1991. Tangible Math is a set of math lessions using J. The dictionary is the language specification. Iverson, "Programming in J", Iverson Software Inc., March 1991. Introduction to programming. Includes J dictionary. McIntyre, "Mastering J", APL91 Conference Proceedings, to appear. Describes one long-time APLer's experience in learning J. ----------------------------------------------------------------- Roger Hui Iverson Software Inc., 33 Major Street, Toronto, Ontario M5S 2K9 (416) 925 6096 -- /s/ Bill Ricker wdr@wang.wang.com "The Freedom of the Press belongs to those who own one." *** Warning: This account is not authorized to express opinions. ***
xtbjh@levels.sait.edu.au (behoffski) (05/17/91)
In article <b5ix83.i25@wang.com>, wdr@wang.com (William Ricker) writes: > > The J dictionary describes nouns (arrays), verbs (functions), adverbs > (monadic operators), and conjunctions (dyadic operators). The new > terminology is readily understandable by a wider audience, and has also > been helpful in suggesting concepts from natural languages which are > fruitful for investigation. > [...] Thanks for this discussion. I'll download the PC version and see if my ideas can be mapped onto J. How close does J get to adjectives, e.g. "all positive elements of array" or "all diagonal elements"? How would you go about implementing a binary tree, and how would you then operate on the "leaf nodes"? How many primitives do you need to specify to implement "leaf nodes"? How easy is it to change the implementation of an operation without changing the original program specification? > ----------------------------------------------------------------- > Roger Hui > Iverson Software Inc., 33 Major Street, Toronto, Ontario M5S 2K9 > (416) 925 6096 > -- Brenton Hoff (behoffski) | Senior Software Engineer | My opinions are mine xtbjh@Levels.UniSA.edu.au | AWA Transponder | (and they're weird).
hui@yrloc.ipsa.reuter.COM (Roger Hui) (05/20/91)
Brenton Hoff writes: > How close does J get to adjectives, e.g. "all positive elements of array" > or "all diagonal elements"? How would you go about implementing a binary > tree, and how would you then operate on the "leaf nodes"? How many > primitives do you need to specify to implement "leaf nodes"? How easy is > it to change the implementation of an operation without changing the > original program specification? a) J does not currently exploit the idea of adjectives. However, I am not sure that adjectives are needed for the examples you cited: "All positive elements of an array" 0&< Proposition indicating positive elements, or #~ 0&<@, Verb to select the actual positive elements "All diagonal elements" =@i.@# Proposition indicating diagonal elements, or (<0 1)&|: Verb to select the actual diagonal elements b) Binary trees can be implemented using boxed arrays. Operations on leaves are usually recursive verbs. c) Many verbs and adverbs are modelled in J itself, and the implementation is quite close to the models in many instances. The programming style in the C implementation is very much an APL style. The paper "APL\?", by Hui, Iverson, McDonnell, and Whitney, in the APL 90 Conference Proceedings, discusses this topic. ----------------------------------------------------------------- Roger Hui Iverson Software Inc., 33 Major Street, Toronto, Ontario M5S 2K9 (416) 925 6096
wdr@wang.com (William Ricker) (05/22/91)
xtbjh@levels.sait.edu.au (behoffski) writes: >How close does J get to adjectives, Quite close if you're careful. There were some very literate APL programs back in the heyday of mainframe timesharing services; Rose's book had some, as I recall. The regularity of the J grammar makes it even easier to design plug-and-play domain specific languages than it had been in APL of yore, and the expressiveness of the built-in adverbs and conjunctions makes compounding simpler than in Forth, I think. I'm afraid generarl purpose analysis of compound nouns, such as the examples given, however, belongs more in comp.ai.n-lang (natural language) -- context really affects how we as humans interpret these phrases. However, we can build J functions which act as english adjectives in the sense of discussing properties and selecting subsets based on properties that will in limited domains compose nicely. > e.g. "all positive elements of array" -- this is a simple enough example I can do it myself without appealing to the COMP.LANG.APL folks for help. ****** First, I'll define synonyms in english for J's key operators ravel=. , **** list the elements of any array -- reduces dim to 1 copy =. # **** select sub-array by selectively copying items; e.g., 1 0 2 0 3 0 0 copy 'abcdefg' acceee ******* Now I'll use the Currying conjunction & to define the concept ******* of a positve number as any number greater than zero. positive =. > & 0 positive 5 1 positive 0 0 positive _3 **** negative 3 ******* applied to an array, it yeilds a binary string A =. _3 + i. 7 A _3 _2 _1 0 1 2 3 positive A 0 0 0 0 1 1 1 ******* that can be given to copy (positive A) copy A 1 2 3 ****** the ~ adverb will reverse the arguments, so we can dispense with ()'s A copy~ positive A 1 2 3 ****** now we define elements to be just ravel if given only right argument ****** and to expect a boolean vector on left of same length as the right ****** which selects which elements of right to keep. elements =. 'ravel y.' : 'x. copy~ y.' elements A _3 _2 _1 0 1 2 3 A elements positive A 1 2 3 (positive A) elements~ A ***** here, the ~ adverb requires ()'s 1 2 3 ****** we can use the (fg) and (gfh) forms to make a compound verb. ****** (as with the Currying adverb & above, this connects to Combinator ****** theory!) ****** if f is monadic, '(fg)y' is just f(g(y)), which is 'f g y' in J syntax. ****** boring but sometimes useful ****** if f is dyadic, '(fg)y' is defined as f(y,g(y)) or 'y f g y' in J ****** and '(gfh)y' as f(g(y),h(y)) or '(g y) f (h y)' in J ****** and 'x(gfh)y' as f(g(x),h(y)) or '(g x) f (h y)' in J (elements positive) A ***** = (positive A) elements A 1 2 3 QED. Getting the coordinatees of the postive elements rather than their values would be equivalent, but I'm not upto it before lunch. >or "all diagonal elements"? diagonal would have to be a function which returned the identity matrix of the same shape ([1 0...0]...[0...0 1] ) (*clipped if rectangular? or undefined? your choice!*). Same elements should work in both cases, but you'd probably need to add a conjunction or adverb to handle squeezing a 2dim array to a 1 dim array in the process; whether this goes in the definition of elements or in the use, I'm not sure. (I'm getting hungrier.) > How would you go about implementing a binary tree, > and how would you then operate on the "leaf nodes"? The new APL's, including J, have boxing operators to encapsulate arrays into new atoms. This allows for ragged arrays and heterogenous arrays and nested arrays. So you can build a binary tree as a recursive structure of 2x1 arrays (3x1 if you want tags!) which bottom-out into something else as leaf-nodes. I haven't thought about this hard, but it is obvious to me that one could easily implement in J the classic Lisp MAP*** functions -- which collect a list of, or return a list of results of appling a function to, all the **** fragments of a structure: J has both recursion and the ability to pass functions as arguments, so higher order functions are no problem. > How easy is >it to change the implementation of an operation without changing the >original program specification? A very good question. The cheap answer is it always depends on whether anyone cheated when using the operation by assuming somthing beyond the specification. The developers of J have considered that mathematicologicians might wish to engage in formal manipulations of J programs and so support a combinator style of definition (used in 'positive' above) as well as the more textual (in 'elements'). J itself is constructed by self-specification. So the culture is there. However, I wouldn't say that the modularity of J is sufficient yet to really support mechanism hiding to the extent that you can have any confidence that only the specification is being relied upon by callers. Boxing itself is a great data-hiding mechanism though -- make the record or whatever an Atom that can only be sensibly unsealed by the module sealing it, and everyone else can just toss it around wherever. Your choice if you have a standard to wrap all Boxed Atoms with a label/tag (roll-your-own object oriented?) or to just have the intended type obvious from context, which takes different discipline (which in a strictly typed language would have been supplied). -- /s/ Bill Ricker wdr@wang.wang.com "The Freedom of the Press belongs to those who own one." *** Warning: This account is not authorized to express opinions. ***