It was not my intention to abolish an existing primitive, but to suggest a new one.
a. I know nothing about designing languages, but I am aware about redundancies in languages, like in J. b. C. can be continued, so this is not an argument against P c. The proposal was restricted to atoms to explain the principle. It should be applicable to any rank. R.E. Boss -----Oorspronkelijk bericht----- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Roger Hui Verzonden: dinsdag 21 maart 2006 6:26 Aan: Programming forum Onderwerp: Re: [Jprogramming] Permuting atom values a. If an objective of language design were to define less primitive functions in terms of more primitive functions, then functions like NAND or NOR would be supreme, over even functions like PLUS and MINUS. b. Cycles have proven to be useful in permutations and permutation groups. It is less obvious that the proposed P function is similarly useful. c. Why are only atom values replaced? ----- Original Message ----- From: "R.E. Boss" <[EMAIL PROTECTED]> To: "'Programming forum'" <[email protected]> Sent: Monday, March 20, 2006 7:36 AM Subject: [Jprogramming] Permuting atom values J does not have a primitive verb which permutes values of atoms, like C. permutes indexes. So, if P would be such a primitive, then (5 0 3; 1 2) P y would replace in y each 5 by 0, each 0 by 3 and each 3 by 5 and swap 1's and 2's. Contrary to the behaviour of C. , preferably P accepts only boxed left hand argument. One way to realize P with the use of C. is: P=: [EMAIL PROTECTED] $ (((i.!.0~ ~.)@] { (((i.&.>~<) C. ]) ~.)) ,) a ; (5 0 3;1 2) P a =: 3 4 [EMAIL PROTECTED] +---------+---------+ |0 5 5 4 2|3 0 0 4 1| |3 2 1 4 2|5 1 2 4 1| |0 2 1 4 1|3 1 2 4 2| |2 4 0 4 0|1 4 3 4 3| | | | |5 4 0 0 0|0 4 3 3 3| |5 1 5 0 4|0 2 0 3 4| |5 5 2 0 0|0 0 1 3 3| |1 1 5 3 1|2 2 0 5 2| | | | |3 2 1 1 3|5 1 2 2 5| |4 4 3 5 5|4 4 5 0 0| |5 0 1 0 3|0 3 2 3 5| |1 3 5 0 1|2 5 0 3 2| +---------+---------+ As can be seen, realizing P using C. can be rather complicated On the other hand, it would be easy to realize C. with the help of P, as C. is a special case of P, applying P to the array of indexes. C. would be (roughly) equal to (P [EMAIL PROTECTED]) { ] (5 0 3;1 2) ((P [EMAIL PROTECTED]) { ]) 'ABCDEF' DCBFEA The conclusion seems to be that P is more primitive than C. What is the opinion of the forum on this? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
