home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / packages / HyperActiveFTP / data.j < prev    next >
Encoding:
Text File  |  1992-04-15  |  14.9 KB  |  472 lines

  1.         Installation and Start-Up Procedure
  2.         for J, Version 3.2, on Unix (TM) systems
  3.  
  4.  
  5. 0.  The compressed tape archive contains the following files:
  6.  
  7.      j                The executable file
  8.      readme.doc            Copyright notice
  9.      status.doc            Implementation status
  10.      install             Something like this file
  11.      message             Message in a Bottle
  12.      isiinfo.doc        Information about ISI
  13.      tutorial.js        Script for running a tutorial
  14.      tut            Sub-directory needed by tutorial.js
  15.      tut/tut*.js        Files needed by tutorial.js
  16.  
  17. 1.  These installation steps are suggested:
  18. Start with the file j_XXX_3.2_.tar.Z, the compressed Tape ARchive
  19. file for the system identified by XXX.
  20.  
  21.      mkdir ~/j            Create a new directory called j.
  22.      mv j_*.tar.Z ~/j        Move the package to the new directory.
  23.      cd ~/j            Change to the new directory.
  24.      uncompress j_*        Expand the compressed tar file.
  25.      tar xof j_*.tar        Extract files from the tape archive.
  26.  
  27. 2.  If yours is a one user system, these steps are suggested:
  28.  
  29.      alias j ~/j/jXXX        Set an alias for j.
  30.      j                To execute the alias.
  31.  
  32. In this way, J will be available to you from any directory.
  33. The J tutorial (mentioned above) will be available to you
  34. whenever you make ~/j your current directory.
  35.  
  36. 3.  When you start J, you should soon see the message
  37.  
  38.    J Version 3.2  Copyright (c) 1990 1991, Iverson Software Inc.
  39.  
  40.    and a 3-space prompt.  At this point, the system is ready to
  41.    interpret J sentences.  To terminate the session, enter   )off  .
  42.  
  43. 4.  A tutorial is available.  Within a session, enter:
  44.  
  45.      )sscript 'tutorial.js'    Make the necessary definitions
  46.      tutorial ''        Start the tutorial
  47.  
  48. 5.  For shared use on a multi-user system, an appropriate installation
  49. is needed.  The directory used for the binary file  j  will depend
  50. on the conventions in use at your installation.  Some system
  51. administrators may like  J  itself to be installed as /bin/j.
  52. The  J  tutorial files may be installed in a different directory,
  53. such as  /software/j/doc.  If this directory path is used, the
  54. files needed by the tutorial would named: 
  55.  
  56.     /software/j/doc/tutorial.js
  57.     /software/j/doc/tut/tut*.js    # (47 of these, numbered 0 to 46)
  58.  
  59. In such a setting, for the file  tutorial.js  to run correctly, it must
  60. be modified.  In this file, the line
  61.  
  62.     frames=.<&read ('tut/tut'&,)&(,&'.js')&:&.>i.47
  63.  
  64. may be replaced by
  65.  
  66.     Path =. '/software/j/doc/tut'
  67.     frames=.<&read ((Path,'/tut')&,)&(,&'.js')&:&.>i.47
  68.  
  69. Then users may be instructed to do these steps,
  70.  
  71.     % cp /software/j/doc/tut/tutorial.js .
  72.     % j
  73.  
  74.           )sscript 'tutorial.js'
  75.           tutorial ''
  76.  
  77. Or users may be instructed to do these steps:
  78.  
  79.     % j
  80.  
  81.         )sscript '/software/j/doc/tutorial.js'
  82.         tutorial ''
  83.  
  84.  
  85. -------------------------------------------------------------------------------
  86.  
  87.                           What is J?
  88.  
  89.             An introduction
  90.                 Part 1
  91.  
  92.  
  93.                  by
  94.  
  95.             Leroy J. Dickey
  96.  
  97.             September, 1991
  98.  
  99.  
  100. J is a high powered general purpose programming language.  This dialect
  101. of APL uses the ASCII character set, has boxed arrays, complex numbers,
  102. and phrasal forms.  Any time one wants to do calculations with more
  103. than one number at a time, or more than one name in a list, a
  104. collective (an array) is the right structure to use, and J is designed
  105. to make it easy to do collective calculations.
  106.  
  107. People who write programs for themselves and who want their answers
  108. quickly will be happy with the swift and concise way programs can be
  109. written in J.
  110.  
  111. This article consists of several examples that illustrate some of the
  112. power of the language J.  In each of the examples presented, output
  113. >from an interactive J session has been captured, and few lines of
  114. explanation have been added.  Lines that are indented with four spaces
  115. are those that were typed in to the J interpreter, and the lines that
  116. are indented with only one space are the responses from J.  Other text
  117. lines are comments that have been added later.  The topics that have
  118. been chosen for inclusion do not come close to telling everything about
  119. J, but some of them represent subjects that at one time or another the
  120. author wished that he had known and understood.
  121.  
  122. Because my professional interests are mathematical, my examples are
  123. primarily mathematical in nature.  But J is a general purpose computing
  124. language, and is well suited to a broad spectrum of programming needs.
  125.  
  126.  
  127. Example 1:  Functional notation
  128.  
  129. This example shows how calculations are done with a list of numbers and
  130. how the notation is functional.  That is, each verb (function) acts on
  131. the data to its right.   It is easy to create a collective.  Here, for
  132. instance, are 9 numbers:
  133.  
  134.     i. 9
  135.  0 1 2 3 4 5 6 7 8
  136.  
  137.     a =. i. 9
  138.     a
  139.  0 1 2 3 4 5 6 7 8
  140.  
  141. The factorials of these numbers are:
  142.     ! a
  143.  1 1 2 6 24 120 720 5040 40320
  144.  
  145. The reciprocals of the above:
  146.     % ! a
  147.  1 1 0.5 0.166667 0.0416667 0.00833333 0.00138889 0.000198413 2.48016e_5
  148.  
  149. And the sum of reciprocals of the factorials of a is:
  150.     +/ % ! a
  151.  2.71828
  152.  
  153.  
  154. Those who know some mathematics may recognize an approximation to the
  155. number ``e'', the base for the natural logarithms.  Of course J has
  156. other ways to calculate this number; the point here is the use of the
  157. natural right to left reading of the meaning of the sequence symbols
  158. +/%!a as the sum of the reciprocals of the factorials of a.
  159.  
  160. Those who have done some programming in almost any other language, will
  161. see that the expression +/%!i.9 is a remarkably short one to produce
  162. an approximation to ``e''.  Moreover, it is possible to pronounce this
  163. program in English in a way that precisely conveys its meaning, and
  164. those who know the meaning of the words in the sentence will be able to
  165. understand it.  And anybody who knows the mathematics and J will
  166. recognize that the program does exactly what the words say and that it
  167. will produce an approximation to ``e''.
  168.  
  169. The author finds this expression in J much easier to think about and
  170. to understand than a corresponding program in a ``traditional'' language
  171. intended to compute the same number.  Here, for example, is what one
  172. might write in Fortran, to accomplish the same result:
  173.  
  174.  
  175.     REAL SUM, FACTRL
  176.     SUM = 1.0
  177.     FACTRL = 1.0
  178.     DO 10 N = 1, 8
  179.         FACTRL = FACTRL * N
  180.         SUM = SUM + 1.0 / FACTRL
  181.      10 CONTINUE
  182.     PRINT, SUM
  183.     STOP
  184.     END
  185.  
  186.  
  187. Compare this Fortran program with the J program that uses only a few
  188. key strokes: +/ % ! i. 9 .  Not only is the J program shorter, but it
  189. is easier to understand, even for the person who has just learned the
  190. meaning of the symbols.  Some have estimated that for typical
  191. applications, the ratio of the number of lines of Fortran or C code to
  192. the number of lines of J code is about 20 to 1.
  193.  
  194.  
  195.  
  196. Example 2:
  197.  
  198. In this example, two verbs are defined.  As before, lines indented
  199. with four spaces were given as input during a J session, and
  200. the ones immediately after, with one leading space, were produced by
  201. the J interpreter.  Other lines are comments, and were added later.
  202.  
  203.  
  204.     Sum =. +/
  205.     Average =. Sum % #
  206.     c =. 1 2 3 4
  207.     Average c
  208.  2.5
  209.  
  210. The first two lines create pro-verbs, the third creates a pro-noun,
  211. and the fourth invokes the function Average with the data c.
  212. The meaning of   Average c  is this:
  213.  
  214.         (+/ % #) 1 2 3 4
  215.  
  216. and this may be thought of as:  find Sum c, (add up the entries
  217. in c), find # c (the count of c), and then find the quotient of those
  218. two results.
  219.  
  220. Example 3:  Continued fractions
  221.  
  222. In this example, the verb ``pr'' (plus reciprocal), is considered.
  223.  
  224.     pr =. +%
  225.  
  226. The next input line shows a use of this hook and you can see that
  227. the meaning is 5 plus the reciprocal of 4:
  228.  
  229.     5 pr 4
  230.  5.25
  231.  
  232.     4 pr 5
  233.  4.2
  234.  
  235. The function pr is defined above as  +% , and this diagram 
  236. for    4 +% 5  may help you to understand its meaning.
  237.  
  238.                      +
  239.                         /                         4    %
  240.                             |
  241.                             5
  242.  
  243. Because of the shape of the diagram, the combination of two verbs
  244. in this way is called a hook.  To continue with our example,
  245.  
  246.     1 pr 1 pr 1            
  247.  1.5
  248.  
  249. The above input line may be read as ``1 plus the reciprocal
  250. of (1 plus the reciprocal of 1)''.  And here below is an analogous
  251. line with four ones:
  252.  
  253.     1 pr 1 pr 1 pr 1
  254.  1.66667
  255.  
  256.     1 pr (1 pr (1 pr 1))
  257.  1.66667
  258.  
  259.     pr / 1 1 1 1        
  260.  1.66667
  261.  
  262.     pr / 4 # 1
  263.  1.66667
  264.  
  265. The above input line has exactly the same meaning as the three input
  266. lines that come before it.  Notice that (of course) the value
  267. of the result is the same.  The / is an adverb called over
  268. and the result of ``pr /'' is a new verb, whose meaning is
  269. derived from the verb ``pr''.
  270.  
  271. This expression could be written another way, using a traditional
  272. mathematical notation the way that mathematicians have been using
  273. to write continued fractions for years:
  274.  
  275.         1
  276.    1 + ------------------------
  277.         1
  278.     1 + ------------------
  279.             1
  280.         1 + ------------
  281.             1
  282.  
  283. This particular continued fraction is a famous one because it is
  284. known to converge to the golden ratio.  That means that if you just
  285. keep on going, with more and more ones, the value gets closer and
  286. closer to the golden ratio.  One can see the values of the continued
  287. fraction expansion converging by using , the scan adverb.  It
  288. creates a sequence of initial sequences.  Here is a nice, compact
  289. expression that shows the values for the first 15 partial continued
  290. fractions.
  291.  
  292.     pr / 15$ 1
  293.  1 2 1.5 1.66667 1.6 1.625 1.61538 1.61905 1.61765 1.61818 1.61798
  294.       1.61806 1.61803 1.61804 1.61803
  295.  
  296. In this, you can see that the numbers seem to be getting closer and
  297. closer to some limit, probably between 1.61803 and 1.61804.  If you
  298. concentrate only on the odd numbered terms, (the first, the third, the
  299. fifth, and so on), you will see a sequence of numbers that is
  300. monotonically increasing.  On the other hand, the even numbered terms,
  301. ( 2, 1.66667, 1.625, and so on), form a sequence of numbers that is
  302. monotonicly decreasing.  Of course these observations do not constitute
  303. a proof of convergence, but they might convince you that a proof can
  304. be found, and in the light of these observations, the proof probably
  305. follows along these lines.
  306.  
  307. Can you think of a simpler way to represent and evaluate continued
  308. fractions?  I can not!
  309.  
  310.  
  311. Example 4.  Using rank operator, and fork.
  312.  
  313. In this example, a second phrasal form, the fork, is discussed.
  314. First some data are built.
  315.  
  316.     a =. 100 200
  317.     b =. 10 20 30
  318.     c =. 1 2 3 4
  319.  
  320. This is the beginning of the data construction.  The verb Sum, a
  321. modification of +, and defined as before, is used.  But in this example,
  322. the usage is different from that used before.  So that you can have a
  323. glimpse at what the dyadic verb Sum does, notice see what it does with
  324. b and c:
  325.  
  326.     b Sum c
  327.  11 12 13 14
  328.  21 22 23 24
  329.  31 32 33 34
  330.  
  331. Once you have seen this example, you are be ready to see and understand
  332. the next step.  Here the collective ``data'' is built, using a, b, and c.
  333.  
  334.     data =. a Sum b Sum c
  335.     data
  336.  111 112 113 114
  337.  121 122 123 124
  338.  131 132 133 134
  339.  
  340.  211 212 213 214
  341.  221 222 223 224
  342.  231 232 233 234
  343.  
  344. This rank three array may be thought of as having has two
  345. planes, with each plane having two rows and three columns.
  346. Now see what Sum does with the data:
  347.  
  348.     Sum data
  349.  322 324 326 328
  350.  342 344 346 348
  351.  362 364 366 368
  352.  
  353. Can you see what is happening?  It is adding up corresponding
  354. elements in the two planes.  Twelve different sums are performed,
  355. and the result is an array that is 3 by 4.
  356.  
  357. But we might wish to add up numbers in rows.  We can do it this way:
  358.  
  359.     Sum 1 data
  360.  450 490 530
  361.  850 890 930
  362.  
  363. And to add up numbers in each column:
  364.  
  365.     Sum 2 data
  366.  363 366 369 372
  367.  663 666 669 672
  368.  
  369. The expressions 1 and 2 are read as 'rank 1' and 'rank 2'.
  370. The rank 1 objects are the rows, and the rank 2 objects are the
  371. planes, and the rank 3 object is the whole object itself.
  372.  
  373. Now, recall the definition of Average.
  374.  
  375.     Average =. Sum % #
  376.  
  377. Now apply this proverb Average to the pronoun data, to get:
  378.  
  379.     Average data
  380.  161 162 163 164
  381.  171 172 173 174
  382.  181 182 183 184
  383.  
  384. The result is the average of corresponding numbers in the two planes.
  385. And, if we would like to know the average of the numbers in the rows,
  386. (remember above, we asked about the sum of the entries in the rows?)
  387. we type:
  388.  
  389.     Average 1 data
  390.  112.5 122.5 132.5
  391.  212.5 222.5 232.5
  392.  
  393. and finally, averaging the columns of the two planes:
  394.  
  395.     Average 2 data
  396.  121 122 123 124
  397.  221 222 223 224
  398.  
  399.  
  400. Again, compare the sizes of these results with the sizes of
  401. the sizes of the results above where we were asking simply about
  402. sums.
  403.  
  404.     Sum 1 data
  405.  450 490 530
  406.  850 890 930
  407.  
  408.     Sum 2 data
  409.  363 366 369 372
  410.  663 666 669 672
  411.  
  412. What is exciting about this example is not only how easily the nouns
  413. (data) and verbs (functions) were built, but how every verb acts in a
  414. uniform and predictable way on the data.  Rank one action is the same
  415. kind of action whether one is summing, or averaging, or whatever.  It
  416. has been said that the concept of rank is one of the top ten ideas to
  417. come along in computing in the last decade.
  418.  
  419. Conclusion:
  420.  
  421. What has been written in this article only begins to scratch the surface
  422. of the power of J, but it does show some of the flavor.
  423. J is powerful because one get results quickly.  It is a programming
  424. language for people who need to write programs for themselves, but
  425. who don't want to spend inordinately large amounts of time getting
  426. their results.  If you have to write programs for others, this could
  427. still be a language for you, if you get paid by the job, and not
  428. by time.
  429.  
  430. Availability:
  431.  
  432. J is available from watserv1.waterloo.edu in the directory
  433. languages/apl/j and is also available from certain other servers, but
  434. the others usually have some specific hardware orientation.  At the
  435. Waterloo site, versions of J are available that run on several kinds of
  436. computers.
  437.  
  438. Learning J:
  439.  
  440. Because J is new, there are not many materials about J yet.
  441. The novice should get a copy of J and let J be the guide and
  442. the interpreter (pun intended).  There is a tutorial that has
  443. tons of material in a small space.  This tutorial comes with
  444. the interpreter, free of charge.  There is also a status.doc
  445. file that comes with J.  This tell what features have been
  446. implemented and which have not.
  447.  
  448. The author of J:
  449.  
  450. The inventor-developer of J is Kenneth E. Iverson, the same man who
  451. invented APL, a real pioneer of computing.  Some years ago, he retired
  452. >from IBM and went to work for I.P.Sharp Associates, a Toronto company
  453. that developed the world's first private packet switching network,
  454. the finest APL available, and was at one time the worlds largest
  455. time sharing service, all APL.  The descendant of this company,
  456. Reuter:file, still has offices in many of the world's major cities.
  457. Now Iverson is retired (again) and lives in Toronto, where he spends
  458. his time developing and promoting J.
  459.  
  460. The programmer for J is Roger Hui.  Roger hails from Edmonton, and has
  461. lived in Toronto since he joined I.P.Sharp Associates in 1975.  The
  462. source code for J, written in C, is worthy of some comment, because it
  463. makes extensive use of macro expansion.  Its style, influenced by the
  464. work of Arthur Whitney of Morgan Stanley in New York, reflects Roger's
  465. strong background in APL.  Today, Roger spends much of his time
  466. developing J and does occasional contract work in APL.
  467.  
  468. Copyright (c) 1991 by Leroy J. Dickey
  469. Permission is granted to use this for
  470. non-profit and educational purposes.
  471. It may be given away, but it may not be sold.
  472.