home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / j / dos / xenos.doc < prev   
Text File  |  1992-10-24  |  15KB  |  447 lines

  1. Copyright (c) 1989 1990, Roger K.W. Hui & K.E. Iverson
  2. Copyright (c) 1990-1992, Iverson Software Inc.
  3. All Rights Reserved.
  4.  
  5.  
  6. Roger Hui
  7. 1992 10 8
  8.  
  9.  
  10. The !: Conjunction:
  11.  
  12. The !: conjunction currently takes integer scalar left and right
  13. arguments, and derives verbs.  (One exception:  5!:0 is an adverb.)
  14. These verbs behave like other verbs; in particular, they have intrinsic
  15. ranks, may be assigned names, and may serve as arguments to adverbs and
  16. conjunctions.  Where these verbs take names as arguments (file names,
  17. WS names, or object names), the names are always boxed, and the verb
  18. rank is 0.
  19.  
  20. As with all other verbs, verbs derived from !: requires one or two
  21. arguments.  Some verbs have no "natural" arguments, but an argument
  22. must nevertheless be supplied (and will be ignored in execution).
  23. For example,
  24.      6!:0 ''
  25.   1991 6 6 10 50 23
  26.  
  27. NYA means not yet available.
  28.  
  29.  
  30. 0!:0      Host System Command
  31.   The string argument is forwarded to the host system for
  32.   execution, and the result is returned as a string with
  33.   embedded new-lines.  For example: 0!:0 'dir *.exe'
  34.  
  35. 0!:1      Spawn
  36.   0!:1 forwards its string argument to the host system for execution,
  37.   like 0!:0, but the output (if any) is ignored.  For example, 0!:1 can
  38.   be used to invoke the vi editor on UNIX systems.
  39.  
  40. 0!:2     Script
  41.  
  42. 0!:3     Silent Script
  43.   Script and Silent Script accept a boxed input file name as right
  44.   argument and an optional boxed output file name as left argument.
  45.   A boxed empty string right argument means "standard input", i.e.
  46.   the keyboard.  The input file consists of lines of J sentences and
  47.   other input lines, and is known as a "script".  The output file is
  48.   suitable for subsequent use as a script.  Script differs from Silent
  49.   Script in that it outputs to the "standard output" (the screen) as
  50.   well as to any output file.  Examples:
  51.  
  52.   (<'sesslog') 0!:2 <''
  53.     Input obtained from the keyboard; output appended to file
  54.     "sesslog" and to the screen.
  55.  
  56.   0!:3 <'\jscripts\asdf'
  57.     Input from file "\jscripts\asdf"; no output.  Input reverts
  58.     to the keyboard at the end of "\jscripts\asdf".
  59.  
  60.   (<'outf') 0!:3 <'disk:folder:subfolder:inf'
  61.     Input obtained from "disk:folder:subfolder:inf"; output
  62.     appended to "outf".
  63.  
  64.   0!:2 <''
  65.     Default.
  66.  
  67.   If there is a file named "profile.js" in the current directory,
  68.   J will automatically execute 0!:2<'profile.js' at the start
  69.   of a session.
  70.  
  71. 0!:4      Lines
  72.  
  73. 0!:5      Silent Lines
  74.   Lines and Silent Lines are like Script and Silent Script, but the right
  75.   argument is a string of lines separated by new-lines.
  76.  
  77. 0!:55     Terminate Session
  78.   0!:55 derives a verb which, when executed, terminates the session.
  79.  
  80. 1!:0      Directory  NYA
  81.  
  82. 1!:1      File Read
  83.   The argument is a boxed file name; the result is a string
  84.   of the file contents.  For example, 1!:1 <'dir\subdir\file.ext'
  85.   The file name follows the conventions of the host system.
  86.   The argument may also be the integer 1, meaning read from
  87.   the keyboard.
  88.  
  89. 1!:2      File Write
  90.   xyz 1!:2 <':folder1:folder2:file'  writes string xyz to the
  91.   specified file.  The right argument may also be the integer 2,
  92.   meaning write to the screen.
  93.  
  94. 1!:3      File Append
  95.   string 1!:3 <'disk:folder1:folder2:file'
  96.  
  97. 1!:4      File Size
  98.   1!:4 'dir/file1';'file2';'phile3'
  99.  
  100. 1!:11     Indexed File Read
  101.   The argument is a 2-element list of boxes: a file name and
  102.   a 2-element integer list of the index and length.  For example,
  103.   1!:11 'test';5 20  reads 20 bytes from file "test", starting
  104.   from position 5.  The index may be negative (the last byte of
  105.   the file is index _1).  The length may be elided, whence the
  106.   file is read from the index to the end of the file.
  107.  
  108. 1!:12     Indexed File Write
  109.   The right argument is a 2-element list of boxes: a file name
  110.   and an integer index.  For example,  xyz 1!:12 'test';14
  111.   writes (string) xyz to file "test", starting at position 14.
  112.   The index may be negative (the last byte of the file is index _1).
  113.   The positions to be written must already exist in the file (and the
  114.   file must already exist).
  115.  
  116. 1!:55     File Erase
  117.   1!:55 <'careful'
  118.  
  119. 2!:0      WS Name Class
  120.   The integer result is the name class (see 4!:0) of the object
  121.   named in the boxed left argument, in the workspace named in
  122.   the boxed right argument.  In the following example, the
  123.   result of the last sentence is 2 3 4.
  124.     wsnc =. 2!:0
  125.     save =. 2!:2
  126.     noun =. i.3 4
  127.     adv  =. /
  128.     save <'wsname'
  129.     ('noun'; 'save'; 'adv') wsnc <'wsname'
  130.  
  131. 2!:1      WS Name List
  132.   The sorted list of all names in the workspace named in the
  133.   boxed right argument.
  134.  
  135. 2!:2      WS Save
  136.   Monad.  Save all global definitions into the workspace named
  137.   in the boxed right argument.  The workspace is created if it
  138.   does not already exist (and is overwritten if it already exists).
  139.  
  140.   Dyad.  Save the global definition of the object named in the
  141.   boxed left argument into the workspace named in the boxed
  142.   right argument.  If the object already exists in the saved
  143.   workspace, it is overwritten; other objects in the saved
  144.   workspace are unaltered.  The workspace is created if
  145.   it does not already exist.
  146.  
  147.   Workspaces are currently in WSIS format (see 5!:3), but may
  148.   use a different format in future J versions.  The workspace
  149.   name follows the file naming rules of the host system.
  150.   It'd be a good idea to devise your own naming convention to
  151.   distinguish workspaces from other files.
  152.  
  153. 2!:3      WS PSave   NYA
  154.   "Protective" Save:  like Save, but the monad does not modify
  155.   an existing workspace, and the dyad does not overwrite
  156.   objects already in the saved workspace.
  157.  
  158. 2!:4      WS Copy
  159.   Copy the object named in the boxed left argument from the
  160.   saved workspace named in the boxed right argument, and define
  161.   it as a global object.  If the left argument is elided, all
  162.   objects in the saved workspace are copied.
  163.  
  164.   Like all verbs, Copy applies to the argument cells in random
  165.   order, so that if an object is copied from more than one
  166.   workspace, the definition of the object could be from any of
  167.   the workspaces.
  168.  
  169. 2!:5      WS PCopy
  170.   "Protective" Copy:  like Copy, but does not overwrite objects
  171.   already defined.
  172.  
  173. 2!:55     WS Erase
  174.   Erase the object named in the boxed left argument, from the
  175.   workspace named in the boxed right argument.
  176.  
  177. 3!:0      Internal Type
  178.   The internal "type" of a noun, where
  179.   1  boolean
  180.   2  literal
  181.   4  integer
  182.   8  floating point
  183.   16 complex
  184.   32 boxed
  185.   64 box with key
  186.  
  187. 3!:1      Convert to   Internal Representation
  188.   A string of the internal representation of a noun.  The result
  189.   is machine-dependent and may differ in different J versions.
  190.  
  191. 3!:2      Convert from Internal Representation
  192.   Inverse of 3!:1, but only nouns of type 2^i.5 are created.
  193.  
  194. 4!:0      Name Class
  195.   The argument is a boxed name; the result is its class:
  196.   _1 other
  197.   0  undefined, but valid name
  198.   1  (not used)
  199.   2  noun
  200.   3  verb
  201.   4  adverb
  202.   5  conjunction
  203.  
  204. 4!:1      Name List
  205.   The argument is a subset of the integers from 2 to 5 (see 4!:0).
  206.   The result is a list of boxed names belonging to the class(es)
  207.   specified in the argument.  The optional left argument are initial
  208.   letters of the names of interest.
  209.  
  210. 4!:55     Erase
  211.   The object named in the boxed argument is erased.
  212.  
  213. 4!:56     Erase given name
  214.  
  215. 5!:0      Fix
  216.   5!:0 is an adverb which defines an object from its atomic or string
  217.   representations.  For example,
  218.  
  219.      fx =. 5!:0
  220.      ar =. 5!:1
  221.      ((ar <'a') fx) -: a =. i. 3 4
  222.   1
  223.      plus =. +
  224.      $$ ar <'plus'
  225.   0
  226.      2 ((ar <'plus') fx) 4 5
  227.   6 7
  228.  
  229.   If the argument is a boxed list of boxes, it is assumed to be
  230.   an atomic representation (a result of 5!:1).
  231.  
  232.   If the argument is a string, it is assumed to be a catenation
  233.   of string representations (results of 5!:3).  The objects are
  234.   defined, names embedded in the representation are assigned
  235.   as a side effect, and the result of 5!:0 is the last
  236.   represented object.
  237.  
  238. 5!:1      Atomic Representation
  239.   The argument is a boxed name; the result is a boxed list of
  240.   two boxes uniquely representing the named object:
  241.  
  242.   noun:         id  value
  243.   verb:         id  operator arguments
  244.   adverb:       id  operator arguments
  245.   conjunction:  id  operator arguments
  246.  
  247.   If an object is uniquely identified by the id alone (for example
  248.   "a." or "+" or "/."), then the second field is elided, and the
  249.   atomic representation is the id alone.
  250.  
  251.   Gerunds (results of the ` conjunction) are arrays of atomic
  252.   representations.  5!:0 defines an object from its atomic
  253.   representation.  Atomic representations are sometimes called
  254.   "canonical" or "boxed" representations.
  255.  
  256. 5!:2      Display Representation
  257.   The argument is a boxed name; the result is the display representation
  258.   of the named object.  5!:0 defines an object from its display
  259.   representation.  (Different objects can have the same display
  260.   representation, so 5!:0 is only a partial inverse.)
  261.      f =. +/ . *
  262.      f
  263.   +-----+-+-+
  264.   |+-+-+|.|*|
  265.   ||+|/|| | |
  266.   |+-+-+| | |
  267.   +-----+-+-+
  268.      each =. &. >
  269.      (5!:2 <'f') -: (, each '+/') ; each '.*'
  270.   1
  271.  
  272. 5!:3      String Representation
  273.   The argument is a boxed name; the result is a string of the WSIS
  274.   (Workspace Interchange Standard) representation of the named object.
  275.   5!:0 defines an object from its string representation.  See Section
  276.   5.3 of "An Implementation of J" for details.
  277.  
  278. 5!:4      Tree Representation
  279.   The argument is a boxed name; the result is a literal table of the
  280.   tree representation of the named object.  Box drawing characters
  281.   (9!:6 and 9!:7) are used to draw the connecting lines in a tree.
  282.   For example,
  283.      nub =. (i.@# = i.~) # ]
  284.      5!:4 <'nub'
  285.                +- i.
  286.          +- @ -+- #
  287.     +----+- =
  288.     |    +- ~ --- i.
  289.   --+- #
  290.     +- ]
  291.  
  292. 5!:5      Linear Representation
  293.   The argument is a boxed name; the result is a string which,
  294.   when interpreted, produces the named object.  For example,
  295.      nub =. (i.@# = i.~) # ]
  296.      5!:5 <'nub'
  297.   (i.@# = i.~) # ]
  298.      $5!:5 <'nub'
  299.   16
  300.      a=.o.i.3 4
  301.      5!:5 <'a'
  302.   3.14159265358979323*i.3 4
  303.  
  304. 6!:0      Time-Stamp
  305.   The current time as a 6-element list: year, month, day, hour,
  306.   minute, and second (including any fraction thereof).
  307.  
  308. 6!:1      Time since session start
  309.  
  310. 6!:2      Time required
  311.   The string right argument is executed the number of times specified
  312.   by the left argument (default: 1).  The execution results are discarded.
  313.   The result of 6!:2 is the average number of seconds required for the
  314.   execution.  For example:
  315.      time=.6!:2
  316.      time '+/i.10000'         NB. time to execute once
  317.      10 time '+/i.10000'      NB. time to execute, averaged over 10 times
  318.  
  319. 6!:3      Delay
  320.   (6!:3) 60 [ 'sleep for a minute'
  321.  
  322. 7!:0      Space currently in use
  323.  
  324. 7!:1      Space used since session start
  325.  
  326. 7!:2      Space required to execute an expression
  327.  
  328. 8!:0      (PC only) Query CGA mode
  329.   (8!:0 ''){'non-CGA mode'; 'CGA mode'
  330.  
  331. 8!:1      (PC only) Set   CGA mode
  332.   (8!:1) 0 [ 'set non-CGA mode'
  333.   (8!:1) 1 [ 'set CGA mode'
  334.  
  335. 8!:4      (PC only) Query screen attributes
  336.  
  337. 8!:5      (PC only) Set   screen attributes
  338.   The argument is a 4 by 2 matrix of integer values from 0 to 15.
  339.   Attribute values are interpreted as follows:
  340.   .---------------------------.
  341.   | input area  | input area  |
  342.   | background  | foreground  |
  343.   |-------------+-------------|  0  black     4  red
  344.   | output area | output area |  1  blue      5  magenta
  345.   | background  | foreground  |  2  green     6  yellow
  346.   |-------------+-------------|  3  cyan      7  white
  347.   | cursor bar  | cursor bar  |
  348.   | background  | foreground  |  8+i values in background specify "flashing";
  349.   |-------------+-------------|  in foreground, "bright".
  350.   | status line | status line |
  351.   | background  | foreground  |
  352.   |_____________|_____________|
  353.  
  354. 8!:7      (PC only) Refresh screen
  355.   Redisplay the contents of the screen.
  356.  
  357. 8!:9      (PC only) Edit
  358.   8!:9 y invokes the editor on y, a string with lines delimited
  359.   by linefeeds (10{a.). Press F1 to get meanings of function keys.
  360.  
  361. 8!:16     (Macintosh only) Query font attributes
  362.  
  363. 8!:17     (Macintosh only) Set   font attributes
  364.   Font attributes are a 3-element integer list of the font number,
  365.   style, and size.  "Style" is the sum of one or more of the following
  366.   integers, where
  367.     1  Bold
  368.     2  Italic
  369.     4  Underline
  370.     8  Outline
  371.   Font attributes can also be set by the font dialog box, invoked
  372.   by the "Font ..." item under the "Edit" menu.
  373.  
  374. 8!:19     (Macintosh only) Print screen
  375.  
  376. 9!:0      Query random link
  377.  
  378. 9!:1      Set   random link.  Default: 16807
  379.  
  380. 9!:2      Query display representation
  381.  
  382. 9!:3      Set   display representation
  383.   The argument is an integer vector of one or more representations
  384.   to be used for default output of verbs, adverbs, and conjunctions.
  385.     1  atomic (gerundial)
  386.     2  display
  387.     3  string
  388.     4  tree
  389.     5  linear
  390.  
  391.   For example:
  392.      nub =. (i.@# = i.~) # ]
  393.      nub
  394.   +-------------------+-+-+
  395.   |+--------+-+------+|#|]|
  396.   ||+--+-+-+|=|+--+-+|| | |
  397.   |||i.|@|#|| ||i.|~||| | |
  398.   ||+--+-+-+| |+--+-+|| | |
  399.   |+--------+-+------+| | |
  400.   +-------------------+-+-+
  401.      9!:3 (5 4)
  402.      nub
  403.   (i.@# = i.~) # ]
  404.               +- i.
  405.     +- @ -+- #
  406.     +---+- =
  407.     |   +- ~ --- i.
  408.   --+- #
  409.     +- ]
  410.  
  411. 9!:4      Query prompt
  412.  
  413. 9!:5      Set   prompt.  Default: '   '
  414.  
  415. 9!:6      Query box drawing characters
  416.  
  417. 9!:7      Set   box drawing characters
  418.   The argument is an 11-element string of  nw,ts,ne, te,cr,tw,
  419.   sw,tn,se, ns,ew  (northwest corner, tee south, northeast
  420.   corner; tee east, etc.)  Defaults:
  421.  
  422.   [PC    ]  218 194 191  195 197 180  192 193 217  179 196 { a.
  423.   [Others]  '+++++++++|-'
  424.  
  425. 9!:8      Query error messages
  426.  
  427. 9!:9      Set   error messages
  428.   For example: Replace English messages (default) with French ones.
  429.  
  430. 10!:k     Link to C function
  431.   For LinkJ, 10!:k invokes the function jc(k,f1,f2).  You must modify
  432.   jc() to assign values to f1 and f2 appropriate to k.  See Appendix C
  433.   of "An Implementation of J" for details.
  434.  
  435. 11!:0     (Windows only) Windows Driver
  436.   See on-line help (press F1).
  437.  
  438. 11!:1     (Windows only) Windows Visual Edit
  439.   The WP string argument is amended via a visual editor.
  440.  
  441. 128!:0    QR decomposition
  442.   The QR decomposition of a complex matrix in the domain of %. .
  443.   The result is an Hermitian matrix and a square upper triangular
  444.   matrix, individually boxed.
  445.  
  446. 128!:1    Invert a square upper triangular matrix
  447.