home *** CD-ROM | disk | FTP | other *** search
/ Math Solutions 1995 October / Math_Solutions_CD-ROM_Walnut_Creek_October_1995.iso / pc / mac / docs_1 / refs.tex < prev    next >
Encoding:
Text File  |  1995-07-17  |  58.5 KB  |  1,548 lines

  1. % Language Reference Card for Yorick version 1
  2. % Function Reference Card for Yorick version 1
  3. % I/O Reference Card for Yorick version 1
  4. % $Id: refs.tex,v 1.1 1993/08/27 18:46:32 munro Exp $
  5.  
  6. %**start of header
  7. \newcount\columnsperpage
  8.  
  9. % This file can be printed with 1, 2, or 3 columns per page (see below).
  10. % Specify how many you want here.  Nothing else needs to be changed.
  11.  
  12. \columnsperpage=3
  13.  
  14. % Based on the refcard.tex file from the GNU Emacs 18.57 distribution:
  15. % Copyright (c) 1987 Free Software Foundation, Inc.
  16.  
  17. % This file is intended to be processed by plain TeX (TeX82).
  18. %
  19. % The final reference card has six columns, three on each side.
  20. % This file can be used to produce it in any of three ways:
  21. % 1 column per page
  22. %    produces six separate pages, each of which needs to be reduced to 80%.
  23. %    This gives the best resolution.
  24. % 2 columns per page
  25. %    produces three already-reduced pages.
  26. %    You will still need to cut and paste.
  27. % 3 columns per page
  28. %    produces two pages which must be printed sideways to make a
  29. %    ready-to-use 8.5 x 11 inch reference card.
  30. %    For this you need a dvi device driver that can print sideways.
  31. % Which mode to use is controlled by setting \columnsperpage above.
  32. %
  33. % Author of GNU Emacs refcard.tex from which this is derived:
  34. %  Stephen Gildea
  35. %  UUCP: mit-erl!gildea
  36. %  Internet: gildea@erl.mit.edu
  37.  
  38. \def\versionnumber{1.1}
  39. \def\year{1995}
  40. \def\version{March \year\ v\versionnumber}
  41.  
  42. \def\shortcopyrightnotice{\vskip 1ex plus 2 fill
  43.   \centerline{\small \copyright\ \year\ Regents of the U. C.
  44.   Permissions on back.  v\versionnumber}}
  45.  
  46. \def\copyrightnotice{
  47. \vskip 1ex plus 2 fill\begingroup\small
  48. \centerline{Copyright \copyright\ \year\
  49.             Regents of the University of California}
  50. \centerline{designed by David Munro, \version}
  51. \centerline{for Yorick version 1}
  52.  
  53. Permission is granted to make and distribute copies of
  54. this card provided the copyright notice and this permission notice
  55. are preserved on all copies.
  56.  
  57. For copies of the Yorick manual, send email to munro@icf.llnl.gov.
  58.  
  59. \endgroup}
  60.  
  61. % make \bye not \outer so that the \def\bye in the \else clause below
  62. % can be scanned without complaint.
  63. \def\bye{\par\vfill\supereject\end}
  64.  
  65. \newdimen\intercolumnskip
  66. \newbox\columna
  67. \newbox\columnb
  68.  
  69. \def\ncolumns{\the\columnsperpage}
  70.  
  71. \message{[\ncolumns\space 
  72.   column\if 1\ncolumns\else s\fi\space per page]}
  73.  
  74. \def\scaledmag#1{ scaled \magstep #1}
  75.  
  76. % This multi-way format was designed by Stephen Gildea
  77. % October 1986.
  78. \if 1\ncolumns
  79.   \hsize 4in
  80.   \vsize 10in
  81.   \voffset -.7in
  82.   \font\titlefont=\fontname\tenbf \scaledmag3
  83.   \font\headingfont=\fontname\tenbf \scaledmag2
  84.   \font\smallfont=\fontname\sevenrm
  85.   \font\smallsy=\fontname\sevensy
  86.  
  87.   \footline{\hss\folio}
  88.   \def\makefootline{\baselineskip10pt\hsize6.5in\line{\the\footline}}
  89. \else
  90.   \hsize 3.2in
  91.   \vsize 7.95in
  92.   \hoffset -.75in
  93.   \voffset -.745in
  94.   \font\titlefont=cmbx10 \scaledmag2
  95.   \font\headingfont=cmbx10 \scaledmag1
  96.   \font\smallfont=cmr6
  97.   \font\smallsy=cmsy6
  98.   \font\eightrm=cmr8
  99.   \font\eightbf=cmbx8
  100.   \font\eightit=cmti8
  101.   \font\eighttt=cmtt8
  102.   \font\eightsy=cmsy8
  103.   \textfont0=\eightrm
  104.   \textfont2=\eightsy
  105.   \def\rm{\eightrm}
  106.   \def\bf{\eightbf}
  107.   \def\it{\eightit}
  108.   \def\tt{\eighttt}
  109.   \normalbaselineskip=.8\normalbaselineskip
  110.   \normallineskip=.8\normallineskip
  111.   \normallineskiplimit=.8\normallineskiplimit
  112.   \normalbaselines\rm        %make definitions take effect
  113.  
  114.   \if 2\ncolumns
  115.     \let\maxcolumn=b
  116.     \footline{\hss\rm\folio\hss}
  117.     \def\makefootline{\vskip 2in \hsize=6.86in\line{\the\footline}}
  118.   \else \if 3\ncolumns
  119.     \let\maxcolumn=c
  120.     \nopagenumbers
  121.   \else
  122.     \errhelp{You must set \columnsperpage equal to 1, 2, or 3.}
  123.     \errmessage{Illegal number of columns per page}
  124.   \fi\fi
  125.  
  126.   \intercolumnskip=.46in
  127.   \def\abc{a}
  128.   \output={%
  129.       % This next line is useful when designing the layout.
  130.       %\immediate\write16{Column \folio\abc\space starts with \firstmark}
  131.       \if \maxcolumn\abc \multicolumnformat \global\def\abc{a}
  132.       \else\if a\abc
  133.     \global\setbox\columna\columnbox \global\def\abc{b}
  134.         %% in case we never use \columnb (two-column mode)
  135.         \global\setbox\columnb\hbox to -\intercolumnskip{}
  136.       \else
  137.     \global\setbox\columnb\columnbox \global\def\abc{c}\fi\fi}
  138.   \def\multicolumnformat{\shipout\vbox{\makeheadline
  139.       \hbox{\box\columna\hskip\intercolumnskip
  140.         \box\columnb\hskip\intercolumnskip\columnbox}
  141.       \makefootline}\advancepageno}
  142.   \def\columnbox{\leftline{\pagebody}}
  143.  
  144.   \def\bye{\par\vfill\supereject
  145.     \if a\abc \else\null\vfill\eject\fi
  146.     \if a\abc \else\null\vfill\eject\fi
  147.     \end}  
  148. \fi
  149.  
  150. % we won't be using math mode much, so redefine some of the characters
  151. % we might want to talk about
  152. % \catcode`\^=12
  153. \catcode`\_=12
  154.  
  155. \chardef\\=`\\
  156. \chardef\{=`\{
  157. \chardef\}=`\}
  158.  
  159. \hyphenation{mini-buf-fer}
  160. \hyphenation{Yor-ick}
  161. \hyphenation{ter-min-ated}
  162.  
  163. \parindent 0pt
  164. \parskip 1ex plus .5ex minus .5ex
  165.  
  166. \def\small{\smallfont\textfont2=\smallsy\baselineskip=.8\baselineskip}
  167.  
  168. \outer\def\newcolumn{\vfill\eject}
  169.  
  170. \outer\def\title#1{{\titlefont\centerline{#1}}\vskip 1ex plus .5ex}
  171.  
  172. \outer\def\section#1{\par\filbreak
  173.   \vskip 3ex plus 2ex minus 2ex {\headingfont #1}\mark{#1}%
  174.   \vskip 2ex plus 1ex minus 1.5ex}
  175.  
  176. \newdimen\keyindent
  177.  
  178. \def\beginindentedkeys{\keyindent=1em}
  179. \def\endindentedkeys{\keyindent=0em}
  180. \endindentedkeys
  181.  
  182. \def\paralign{\vskip\parskip\halign}
  183.  
  184. \def\<#1>{$\langle${\rm #1}$\rangle$}
  185.  
  186. \def\kbd#1{{\tt#1}\null}    %\null so not an abbrev even if period follows
  187.  
  188. \def\beginexample{\leavevmode\begingroup
  189.   \obeylines\obeyspaces\parskip0pt\tt}
  190. {\obeyspaces\global\let =\ }
  191. \def\endexample{\endgroup}
  192.  
  193. \def\key#1#2{\leavevmode\hbox to \hsize{\vtop
  194.   {\hsize=.75\hsize\rightskip=1em
  195.   \hskip\keyindent\relax#1}\kbd{#2}\hfil}}
  196.  
  197. \def\func#1#2{\leavevmode\hbox to \hsize{\hbox to \hsize
  198.   {\hskip\keyindent\relax\kbd{#1}\hfil}%
  199.   \hskip 0pt minus 1fil
  200.   \null#2\hfil}}
  201.  
  202. \def\sample#1#2{\leavevmode\hbox to \hsize{\hbox to \hsize
  203.   {\hskip\keyindent\relax#1\hfil}%
  204.   \hskip 0pt minus 1fil
  205.   \null#2\hfil}}
  206.  
  207. \def\begindemo{\leavevmode\begingroup
  208.   \obeylines\obeyspaces\parskip0pt}
  209. % {\obeyspaces\global\let =\ }
  210. \def\enddemo{\endgroup}
  211.  
  212. %**end of header
  213.  
  214.  
  215. %----------------------------------------------------------------------------
  216.  
  217. \title{Yorick Language Reference}
  218.  
  219. \centerline{(for version 1)}
  220.  
  221. \section{Starting and Quitting Yorick}
  222.  
  223. To enter Yorick, just type its name: \hglue1em \kbd{yorick}
  224.  
  225. \key{normal Yorick prompt}{>}
  226. \key{prompt for continued line}{cont>}
  227. \key{prompt for continued string}{quot>}
  228. \key{prompt for continued comment}{comm>}
  229. \key{prompt in debug mode}{dbug>}
  230.  
  231. \func{quit}{close all open files and exit Yorick}
  232.  
  233. \section{Getting Help}
  234.  
  235. Most Yorick functions have online documentation.
  236.  
  237. \func{help}{help on using Yorick help}
  238. \func{help, f}{help on a specific function f}
  239. \func{info, v}{information about a variable v}
  240.  
  241. \section{Error Recovery}
  242.  
  243. \key{To abort a running Yorick program type}{C-c}
  244.  
  245. To enter Yorick's debug mode after an error, type return in response
  246. to the first prompt after the error occurs.
  247.  
  248. \section{Array Data Types}
  249.  
  250. The basic data types are:
  251.  
  252. \func{char}{one 8-bit byte, from 0 to 255}
  253. \func{short}{compact integer, at least 2 bytes}
  254. \func{int}{{\bf logical results}-- 0 false, 1 true, at least 2 bytes}
  255. \func{long}{{\bf default integer}-- at least 4 bytes}
  256. \func{float}{at least 5 digits, $10^{\pm38}$}
  257. \func{double}{{\bf default real}-- 14 or 15 digits, usually $10^{\pm308}$}
  258. \func{complex}{{\bf re} and {\bf im} parts are double}
  259. \func{string}{0-terminated text string}
  260. \func{pointer}{pointer to an array}
  261.  
  262. A compound data type {\it compound\_type} can be built from any combination
  263. of basic or previously defined data types as follows:
  264. \begindemo
  265. \hglue1em\kbd{struct} {\it compound\_type} \kbd{\{}
  266. \hglue2em {\it type\_name\_A memb\_name\_1} \kbd{;}
  267. \hglue2em {\it type\_name\_B memb\_name\_2(dimlist)} \kbd{;}
  268. \hglue2em {\it type\_name\_C memb\_name\_3,memb\_name\_4(dimlist)} \kbd{;}
  269. \hglue2em ...
  270. \hglue1em\kbd{\}}
  271. \enddemo
  272. A {\it dimlist} is a comma delimited list of dimension lengths, 
  273. or lists in the format returned by the \kbd{dimsof} function, or
  274. ranges of the form \kbd{min\_index : max\_index}.  (By default,
  275. \kbd{min\_index} is 1.)
  276.  
  277. For example, the \kbd{complex} data type is predefined as:
  278. \begindemo
  279. \hglue1em\kbd{struct complex \{ double re, im; \}}
  280. \enddemo
  281.  
  282. \shortcopyrightnotice
  283.  
  284. \section{Constants}
  285.  
  286. By default, an integer number is a constant of type \kbd{long}, and
  287. a real number is a constant of type \kbd{double}.  Constants of the
  288. types \kbd{short}, \kbd{int}, \kbd{float}, and \kbd{complex} are
  289. specified by means of the suffices \kbd{s}, \kbd{n}, \kbd{f}, and
  290. \kbd{i}, respectively.  Here are some examples:
  291.  
  292. \func{char}{{\tt '\\0', '\\1', '\\x7f', '\\177', 'A', '\\t'}}
  293. \func{short}{{\tt 0s, 1S, 0x7fs, 0177s, -32766s}}
  294. \func{int}{{\tt 0N, 1n, 0x7Fn, 0177n, -32766n}}
  295. \func{long}{{\tt 0, 1, 0x7f, 0177, -32766, 1234L}}
  296. \func{float}{{\tt .0f, 1.f, 1.27e2f, 0.00127f, -32.766e3f}}
  297. \func{double}{{\tt 0.0, 1.0, 127.0, 1.27e-3, -32.766e-33}}
  298. \func{complex}{{\tt 0i, 1i, 127.i, 1.27e-3i, -32.766e-33i}}
  299. \func{string}{{\tt "", "Hello, world!", "\\tTab\\n2nd line"}}
  300.  
  301. The following escape sequences are recognized in type \kbd{char} and
  302. type \kbd{string} constants:
  303.  
  304. \keyindent=6em
  305. \func{\\n}{newline\hglue6em}
  306. \func{\\t}{tab\hglue6em}
  307. \func{\\"}{double quote\hglue6em}
  308. \func{\\'}{single quote\hglue6em}
  309. \func{\\\\}{backslash\hglue6em}
  310. \func{\\ooo}{octal number\hglue6em}
  311. \func{\\xhh}{hexadecimal number\hglue6em}
  312. \func{\\a}{alert (bell)\hglue6em}
  313. \func{\\b}{backspace\hglue6em}
  314. \func{\\f}{formfeed (new page)\hglue6em}
  315. \func{\\r}{carriage return\hglue6em}
  316. \endindentedkeys
  317.  
  318. \section{Defining Variables}
  319.  
  320. \sample{{\it var} {\tt =} {\it expr}}
  321.        {redefines {\it var\/} as the value of {\it expr}}
  322. \sample{{\it var} {\tt = [ ]}}
  323.        {undefines {\it var}}
  324.  
  325. Any previous value or data type of {\it var} is forgotten.
  326. The {\it expr\/} can be a data type, function, file, or any other object.
  327.  
  328. The \kbd{=} operator is a binary operator which has the side effect of
  329. redefining its left operand.  It associates to the right, so
  330.  
  331. \sample{{\it var1} {\tt =} {\it var2} {\tt =} {\it var3} {\tt =} {\it expr}}
  332.        {initializes all three {\it var\/} to {\it expr}}
  333.  
  334. \section{Arithmetic and Comparison Operators}
  335.  
  336. From highest to lowest precedence, 
  337.  
  338. \keyindent=3em
  339. \func{\^{}}{raise to power\hglue3em}
  340. \func{* / \%}{multiply, divide, modulo\hglue3em}
  341. \func{+ -}{add, subtract (also unary plus, minus)\hglue3em}
  342. \func{<< >>}{shift left, shift right\hglue3em}
  343. \func{>= < <= >}
  344.      {(not) less, (not) greater (\kbd{int} result)\hglue3em}
  345. \func{== !=}{equal, not equal (\kbd{int} result)\hglue3em}
  346. \func{\&}{bitwise and\hglue3em}
  347. \func{\~{}}{bitwise xor (also unary bitwise complement)\hglue3em}
  348. \func{|}{bitwise or\hglue3em}
  349. \func{=}{redefine or assign\hglue3em}
  350. \endindentedkeys
  351.  
  352. Any binary operator may be prefixed to \kbd{=} to produce an increment
  353. operator; thus \kbd{x*=5} is equivalent to \kbd{x=x*5}.  Also, \kbd{++x}
  354. and \kbd{--x} are equivalent to \kbd{x+=1} and \kbd{x-=1}, respectively.
  355. Finally, \kbd{x++} and \kbd{x--} increment or decrement \kbd{x} by 1, but
  356. return the value of \kbd{x} {\bf before} the operation.
  357.  
  358. \section{Creating Arrays}
  359.  
  360. \sample{{\tt [} {\it obj1, obj2, ..., objN} {\tt ]}}
  361.        {build an array of N objects}
  362. The {\it objI} may be arrays to build multi-dimensional arrays.
  363.  
  364. \sample{\kbd{array(}{\it value, dimlist\/}\kbd{)}}
  365.        {add dimensions {\it dimlist\/} to {\it value}}
  366. \sample{\kbd{array(}{\it type\_name, dimlist\/}\kbd{)}}
  367.        {return specified array, all zero}
  368.  
  369. \sample{\kbd{span(}{\it start, stop, n\/}\kbd{)}}
  370.        {{\it n} equal stepped values from {\it start\/} to {\it stop}}
  371. \sample{\kbd{spanl(}{\it start, stop, n\/}\kbd{)}}
  372.        {{\it n} equal ratio values from {\it start\/} to {\it stop}}
  373. \sample{\kbd{grow, }{\it var, sfx1, sfx2, ...}}
  374.        {append {\it sfx1}, {\it sfx1}, etc. to {\it var}}
  375. These functions may be used to generate multi-dimensional arrays;
  376.  use \kbd{help} for details.
  377.  
  378. \section{Indexing Arrays}
  379.  
  380. \sample{{\it x}{\tt (}{\it index1, index2, ..., indexN\/}{\tt )}}
  381.        {is a subarray of the array {\it x}}
  382.  
  383. Each index corresponds to one dimension of the {\it x} array, called
  384. the {\bf ID} in this section (the two exceptions are noted below).
  385. The {\it index1\/} varies fastest, {\it index2\/} next fastest, and so
  386. on.  By default, Yorick indices are 1-origin.  An {\it indexI\/} may
  387. specify multiple index values, in which case the result array will
  388. have one or more dimensions which correspond to the {\bf ID} of
  389. {\it x}.  Possibilities for the {\it indexI} are:
  390.  
  391. \hangindent=1em
  392. \hangafter=1
  393. $\bullet$ scalar index \hfil\break
  394. Select one index.  No result dimension will correspond to {\bf ID}.
  395.  
  396. \hangindent=1em
  397. \hangafter=1
  398. $\bullet$ nil (or omitted) \hfil\break
  399. Select the entire {\bf ID}.  One result dimension will match the {\bf ID}.
  400.  
  401. \hangindent=1em
  402. \hangafter=1
  403. $\bullet$ index range \hglue 1em \kbd{start:stop} or
  404. \kbd{start:stop:step} \hfil\break
  405. Select \kbd{start}, \kbd{start+step}, \kbd{start+2*step}, etc.  One
  406. result dimension of length \kbd{1+(stop-start)/step} and origin 1
  407. will correspond to {\bf ID}.  The default \kbd{step} is 1; it may be
  408. negative.  In particular, \kbd{::-1} reverses the order of {\bf ID}.
  409.  
  410. \hangindent=1em
  411. \hangafter=1
  412. $\bullet$ index list \hfil\break
  413. Select an arbitrary list of indices -- the index list can be any array of
  414. integers.  The dimensions of the index list will replace the {\bf ID} in
  415. the result.
  416.  
  417. \hangindent=1em
  418. \hangafter=1
  419. $\bullet$ pseudo-index \hglue 1em \kbd{-} \hfil\break
  420. Insert a unit length dimension in the result which was not present in the 
  421. original array {\it x}.  There is no {\bf ID} for a \kbd{-} index.
  422.  
  423. \hangindent=1em
  424. \hangafter=1
  425. $\bullet$ rubber-index \hglue 1em \kbd{..} \hglue 1em or
  426.                        \hglue 1em \kbd{*} \hfil\break
  427. The {\bf ID} may be zero or more dimensions of {\it x}, forcing {it indexN\/}
  428. to be the final actual index of {\it x}.  A \kbd{..} preserves the actual
  429. indices, \kbd{*} collapses them to a single index.
  430.  
  431. \hangindent=1em
  432. \hangafter=1
  433. $\bullet$ range function {\it ifunc\/} or {\it ifunc\/}:range \hfil\break
  434. Apply a range function to all or a subset of the {\bf ID}; the other
  435. dimensions are ``spectators''; multiple {\it ifunc\/} are performed
  436. successively from left to right.
  437.  
  438. Function results and expressions may be indexed directly, e.g.:
  439. \hfil\break
  440. \hglue0.5em{\it f\/}{\tt (}{\it a,b,c\/}{\tt )(}{\it index1,index2\/}{\tt )}
  441. or
  442. {\tt (}$2*x+1${\tt )(}{\it index1,index2,index3\/}{\tt )}
  443.  
  444. If the left hand operand of the \kbd{=} operator is an indexed array, the
  445. right hand side is converted to the type of the left, and the specified
  446. array elements are replaced.  Do not confuse this with the redefinition
  447. operation {\it var}{\tt =}:
  448.  
  449. \sample{{\it x}{\tt (}{\it index1, index2, ..., indexN\/}{\tt )=} {\it expr}}
  450.        {assign to a subarray of {\it x}}
  451.  
  452. \section{Array Conformability Rules}
  453.  
  454. Operands may be arrays, in which case the operation is performed on
  455. each element of the array(s) to produce an array result.  Binary
  456. operands need not have identical dimensions, but their dimensions must
  457. be {\it conformable}.  Two arrays are conformable if their first
  458. dimensions {\it match}, their second dimensions {\it match}, their
  459. third dimensions {\it match}, and so on up to the number of dimensions in
  460. the array with the fewer dimensions.  Two array dimensions {\it match\/}
  461. if either of the following conditions is met:
  462.  
  463. $\bullet$ the dimensions have the same length
  464.  
  465. $\bullet$ one of the dimensions has unit length (1 element)
  466.  
  467. Unit length or missing dimensions are broadcast (by copying the single
  468. value) to the length of the corresponding dimension of the other
  469. operand.  The result of the operation has the number of dimensions of
  470. the higher rank operand, and the length of each dimension is the
  471. longer of the lengths in the two operands.
  472.  
  473. \section{Logical Operators}
  474.  
  475. Yorick supports C-style logical AND and OR operators.  Unlike
  476. the arithmetic and comparison operators, these take only scalar
  477. operands and return a scalar \kbd{int} result.  Their precedence
  478. is between \kbd{|} and \kbd{=}.
  479.  
  480. The right operand is not evaluated at all if the value of the
  481. left operand decides the result value; hence the left operand
  482. may be used to determine whether the evaluation of the right
  483. operand would lead to an error.
  484.  
  485. \keyindent=3em
  486. \func{\&\&}{logical and (scalar \kbd{int} result)\hglue3em}
  487. \func{||}{logical or (scalar \kbd{int} result)\hglue3em}
  488. \endindentedkeys
  489.  
  490. The logical NOT operator takes an array or a scalar operand, returning
  491. \kbd{int} 1 if the operand was zero, 0 otherwise.  Its precedence is
  492. above \kbd{\^{}}.
  493.  
  494. \keyindent=3em
  495. \func{!}{logical not (\kbd{int} result)\hglue3em}
  496. \endindentedkeys
  497.  
  498. The ternary operator selects one of two values based on the value of a
  499. scalar {\it condition}: \hfil\break
  500. \hglue4em {\it condition} \kbd{?} {\it true\_expr} \kbd{:} {\it false\_expr}
  501. \hfil\break
  502. Its precedence is low, and it must be parenthesized in a function argument
  503. list or an array index list to prevent confusion with the \kbd{:} in the
  504. index range syntax.  Like \kbd{\&\&} and \kbd{||}, the expression which is
  505. rejected is not evaluated at all.
  506.  
  507. \section{Calling Functions}
  508.  
  509. \sample{{\it f\/}\kbd{(}{\it arg1, ..., argN\/}\kbd{)}}
  510.        {invoke {\it f} as a function}
  511. \sample{{\it f\/}\kbd{, }{\it arg1, ..., argN\/}}
  512.        {invoke {\it f} as a subroutine, discard return}
  513.  
  514. Arguments which are omitted are passed to the function as nil.  In addition
  515. to positional arguments, a function (invoked by either of the above two
  516. mechanisms).  Keyword arguments look like this:
  517.  
  518. \hglue2em
  519. {\it f\/}\kbd{, }{\it arg1, keyA= exprA, keyB= exprB, arg2, ...\/}
  520.  
  521. where {\it keyA} and {\it keyB} are the names of keyword arguments of the
  522. function {\it f}.  Omitted keywords are passed to {\it f} as nil values.
  523. Keywords typically set optional values which have defaults.
  524.  
  525. \section{Defining Functions}
  526.  
  527. \def\indf{\hglue1em\kbd{func}}
  528.  
  529. A function of N dummy arguments is defined by:
  530. \begindemo
  531. \indf {\it func\_name\/}\kbd{(}{\it dummy1, dummy2, ..., dummyN\/}\kbd{)}
  532. \hglue1em\kbd{\{}
  533. \hglue2em {\it body\_statements}
  534. \hglue1em\kbd{\}}
  535. \enddemo
  536.  
  537. If the function has no dummy arguments, the first line of the
  538. definition should read:
  539. \begindemo
  540. \indf {\it func\_name\/}
  541. \enddemo
  542.  
  543. Mark output parameters with a \kbd{\&}, as {\it dummy2} here:
  544. \begindemo
  545. \indf {\it func\_name\/}\kbd{(}{\it dummy1, \kbd{\&}dummy2, dummy3\/}\kbd{)}
  546. \enddemo
  547.  
  548. If the function will take keyword arguments, they must be listed after all
  549. positional arguments and marked by a \kbd{=}:
  550. \begindemo
  551. \indf {\it func\_name\/}\kbd{(}{\it ..., dummyN, key1=, ..., keyN=}\kbd{)}
  552. \enddemo
  553.  
  554. If the function allows an indeterminate number of positional arguments
  555. (beyond those which can be named), place the special symbol \kbd{..} after
  556. the final dummy argument, but before the first keyword.  For example, to
  557. define a function which takes one positional argument, followed by an
  558. indeterminate number of positional arguments, and one keyword, use:
  559. \hfil\break
  560. \indf\hglue.7em {\it func\_name\/}\kbd{(}{\it dummy1, \kbd{..}, key1=}\kbd{)}
  561. \hfil\break
  562. The function \kbd{more_args()} returns the number of unread actual
  563. arguments corresponding to the \kbd{..} indeterminate dummy argument.
  564. The function \kbd{next_arg()} reads and returns the next unread actual
  565. argument, or nil if all have been read.
  566.  
  567. \section{Variable Scope}
  568.  
  569. \sample{\kbd{local} {\it var1, var2, ..., varN}}
  570.        {give the {\it varI} local scope}
  571. \sample{\kbd{extern} {\it var1, var2, ..., varN}}
  572.        {give the {\it varI} external scope}
  573.  
  574. If a variable {\it var} has local scope within a function, any value
  575. associated with {\it var} is temporarily replaced by nil on entry to
  576. the function.  On return from the function, the external value of {\it
  577. var} is restored, and the local value is discarded.
  578.  
  579. If a variable {\it var} has external scope within a function,
  580. references to {\it var} within the function refer to the {\it var} in
  581. the ``nearest'' calling function for which {\it var} has local scope
  582. (that is, to the most recently created {\it var}).
  583.  
  584. The \kbd{*main*} function has no variables of local scope; all
  585. variables created at this outermost level persist until they are
  586. explicitly undefined or redefined.
  587.  
  588. Dummy or keyword arguments always have local scope.
  589.  
  590. In the absence of a \kbd{extern} or \kbd{local} declaration, a variable
  591. {\it var} has local scope if, and only if, its first use within the
  592. function is as the left operand of a redefinition, {\it var\/}\kbd{=}
  593. {\it expr}.
  594.  
  595. \section{Returning from Functions}
  596.  
  597. \sample{\kbd{return} {\it expr}}{return {\it expr} from current function}
  598. The {\it expr} may be omitted to return nil, which is the default
  599. return value if no \kbd{return} statement is encountered.
  600.  
  601. \sample{\kbd{exit,} {\it msg}}{return from all functions, printing {\it msg}}
  602. \sample{\kbd{error,} {\it msg}}{halt with error, printing {\it msg}}
  603.  
  604. \section{Compound Statements}
  605.  
  606. Yorick statements end with a \kbd{;} or end-of-line if the resulting
  607. statement would make sense.
  608.  
  609. Several Yorick statements can be combined into a single compound
  610. statement by enclosing them in curly braces:
  611. \begindemo
  612. \hglue1em \kbd{\{}
  613. \hglue2em {\it statement1}
  614. \hglue2em {\it statement2}
  615. \hglue2em ...
  616. \hglue1em \kbd{\}}
  617. \enddemo
  618. The bodies of most loops and \kbd{if} statements are compound.
  619.  
  620. \section{Conditional Execution}
  621.  
  622. A Yorick statement can be executed or not based on the value of a
  623. scalar {\it condition} (0 means don't execute, non-0 means execute):
  624. \begindemo
  625. \hglue1em \kbd{if (}{\it condition\/}\kbd{)} {\it statementT}
  626. \enddemo
  627. or, more generally,
  628. \begindemo
  629. \hglue1em \kbd{if (}{\it condition\/}\kbd{)} {\it statementT}
  630. \hglue1em \kbd{else} {\it statementF}
  631. \enddemo
  632.  
  633. Several \kbd{if} statements may be chained as follows:
  634. \begindemo
  635. \hglue1em \kbd{if (}{\it condition1\/}\kbd{)} {\it statement1}
  636. \hglue1em \kbd{else if (}{\it condition2\/}\kbd{)} {\it statement2}
  637. \hglue1em \kbd{else if (}{\it condition3\/}\kbd{)} {\it statement3}
  638. \hglue1em ...
  639. \hglue1em \kbd{else} {\it statementF}
  640. \enddemo
  641.  
  642. \section{Loops}
  643.  
  644. Yorick has three types of loops:
  645. \begindemo
  646. \hglue1em\kbd{while (}{\it condition\/}\kbd{)} {\it body\_statement}
  647. \hglue1em\kbd{do} {\it body\_statement\/} \kbd{while (}{\it condition\/}\kbd{)}
  648. \hglue1em\kbd{for (}{\it init\_expr \kbd{;} test\_expr \kbd{;} inc\_expr\/}\kbd{)} {\it body\_statement}
  649. \enddemo
  650. The {\it init\_expr} and {\it inc\_expr} of a \kbd{for} loop may be comma
  651. delimited lists of expressions.  They or the {\it test\_expr} may be
  652. omitted.  In particular, \kbd{for (;;) ...} means ``do forever''.  If
  653. there is a {\it test\_expr}, the {\it body\_statement} of the \kbd{for} loop
  654. will execute until it becomes false (possibly never executing).  After
  655. each pass, but before the {\it test\_expr}, the {\it inc\_expr} executes.
  656. A \kbd{for} loop to make N passes through its {\it body\_statement} might
  657. look like this: \hfil\break
  658. \hglue1em\kbd{for (i=1 ; i<=N ; i++)} {\it body\_statement}
  659.  
  660.  
  661. Within a loop body, the following statements are legal:
  662.  
  663. \func{break}{exit the current loop now}
  664. \func{continue}{abort the current pass through the current loop}
  665.  
  666. For more complex flow control, Yorick supports a \kbd{goto}:
  667.  
  668. \sample{\kbd{goto} {\it label}}{go to the statement after {\it label}}
  669. \sample{{\it label\/}\kbd{:} {\it statement}}
  670.        {mark {\it statement} as a \kbd{goto} target}
  671.  
  672. \copyrightnotice
  673.  
  674. \par\vfill\supereject
  675.  
  676. %----------------------------------------------------------------------------
  677.  
  678. \title{Yorick Function Reference}
  679.  
  680. \centerline{(for version 1)}
  681.  
  682. \section{Including Source Files}
  683.  
  684. \func{\#include "{\it filename.i\/}"}{insert contents of {\it filename}}
  685.  
  686. This is a parser directive, NOT an executable statement.  Yorick also
  687. provides two forms of executable include statements:
  688.  
  689. \func{include, "{\it filename.i\/}"}{parse contents of {\it filename.i}}
  690. \func{require, "{\it filename.i\/}"}{parse {\it filename.i} if not yet parsed}
  691.  
  692. The effect of the \kbd{include} function is not quite immediate, since
  693. any tasks (\kbd{*main*} programs) generated cannot execute until the
  694. task which called \kbd{include} finishes.
  695.  
  696. The \kbd{require} function should be placed at the top of a file which
  697. represents a package of Yorick routines that depends on functions or
  698. variables defined in another package {\it filename.i}.
  699.  
  700. The {\it filename.i\/} ends with a \kbd{.i} suffix by convention.
  701.  
  702. \section{Comments}
  703.  
  704. \hglue1em \kbd{/* Yorick comments begin with slash-asterisk, \hfil\break
  705. \hglue2.5em  and end with asterisk-slash.  A comment \hfil\break
  706. \hglue2.5em  of any size is treated as a single blank.  */}
  707.  
  708. Since \kbd{/* ... */} comments do not nest properly, Yorick supports
  709. C++ style comments as well:
  710. \begindemo
  711. \hglue1em \kbd{statement   //} remainder of line is comment (C++)
  712. \hglue1em \kbd{//} Prefix a double slash to each line to comment out
  713. \hglue1em \kbd{//} a block of lines, which may contain comments.
  714. \enddemo
  715.  
  716. \section{Issuing Shell Commands}
  717.  
  718. You can execute a system command, returning to Yorick when
  719. the command completes, by prefixing the command line with \kbd{\$}:
  720.  
  721. \hglue1em \kbd{\$}any shell command line
  722.  
  723. This is a shorthand for the \kbd{system} function:
  724.  
  725. \func{system, {\it shell\_string}}{pass {\it shell\_string} to a system shell}
  726.  
  727. You need to use the \kbd{system} function if you want to compute the
  728. {\it shell\_string}; otherwise \kbd{\$} is more convenient.
  729.  
  730. Note that the cd (change directory) shell command and its relatives
  731. will not have any effect on Yorick's working directory.  Instead, use
  732. Yorick's \kbd{cd} function to change it's working directory:
  733.  
  734. \func{cd, {\it path\_name}}{change Yorick's default directory}
  735. \func{get_cwd()}{return Yorick's current working directory}
  736.  
  737. The following functions also relate to the operating system:
  738.  
  739. \func{get_home()}{return your home directory}
  740. \func{get\_env({\it env\_string\/})}
  741.      {return environment variable {\it env\_string\/}}
  742. \func{get\_argv()}{return the command line arguments}
  743.  
  744. \shortcopyrightnotice
  745.  
  746. \section{Matrix Multiplication}
  747.  
  748. The \kbd{*} binary operator normally represents the product of its
  749. operands element-by-element, following the same conformability rules
  750. as the other binary operators.  However, by marking one dimension of
  751. its left operand and one dimension of its right operand with \kbd{+},
  752. \kbd{*} will be interpreted as a matrix multiply along the marked
  753. dimensions.  The marked dimensions must have the same length.  The result
  754. will have the unmarked dimensions of the left operand, followed by the
  755. unmarked dimensions of the right operand.
  756.  
  757. For example, if \kbd{x} is a 12-by-25-by-35 array, \kbd{y} and \kbd{z} are
  758. vectors of length 35, and \kbd{w} is a 9-by-12-by-7 array, then:
  759.  
  760. \func{x(,,+)*y(+)}{is a 12-by-25 array}
  761. \func{y(+)*z(+)}{is the inner product of \kbd{y} and \kbd{z}}
  762. \func{x(+,,)*w(,+,)}{is a 25-by-35-by-9-by-7 array}
  763.  
  764. \section{Using Pointers}
  765.  
  766. A scalar of type \kbd{pointer} points to a Yorick array of any data
  767. type or dimensions.  Unary \kbd{\&} returns a \kbd{pointer} to its
  768. argument, which can be any array valued expression.  Unary \kbd{*}
  769. dereferences its argument, which must be a scalar of type
  770. \kbd{pointer}, returning the original array.  A dereferenced pointer
  771. may itself be an array of type \kbd{pointer}.  The unary \kbd{\&} and
  772. \kbd{*} bind more tightly than any other Yorick operator except
  773. \kbd{.} and \kbd{->} (the member extraction operators), and array
  774. indexing {\it x\/}\kbd{(..)}:
  775.  
  776. \keyindent=2em
  777. \sample{\kbd{\&}{\it expr}}
  778.        {return a scalar \kbd{pointer} to {\it expr}\hglue2em}
  779. \sample{\kbd{*}{\it expr}}
  780.        {dereference {\it expr}, a scalar pointer\hglue2em}
  781. \endindentedkeys
  782.  
  783. Since a \kbd{pointer} always points to a Yorick array, Yorick can
  784. handle all necessary memory management.  Dereference \kbd{*} or
  785. \kbd{->}, copy by assignment \kbd{=}, or compare to another pointer
  786. with \kbd{==} or \kbd{!=} are the only legal operations on a \kbd{pointer}.
  787. A pointer to a temporary {\it expr} makes sense and may be useful.
  788.  
  789. The purpose of the \kbd{pointer} data type is to deal with several related
  790. objects of different types or shapes, where the type or shape changes,
  791. making \kbd{struct} inapplicable.
  792.  
  793. \section{Instancing Data Structures}
  794.  
  795. Any data type {\it type\_name} --- basic or defined by \kbd{struct}
  796. --- serves as a type converter to that data type.  A nil argument is
  797. converted to a scalar zero of the specified type.  Keywords matching
  798. the member names can be used to assign non-zero values to individual
  799. members:
  800.  
  801. \func{{\it type\_name}()}{scalar instance of {\it type\_name}, zero value}
  802. \func{{\it type\_name}({\it memb\_name\_1}={\it expr\_1},...)}
  803.      {scalar {\it type\_name}}
  804.  
  805. The \kbd{.} operator extracts a member of a data structure.  The
  806. \kbd{->} operator dereferences a pointer to the data structure before
  807. extracting the member.  For example:
  808. \beginexample
  809. struct Mesh \{ pointer x, y; long imax, jmax; \}
  810. mesh= Mesh(x=\&xm,
  811.            imax=dimsof(xm)(1), jmax=dimsof(xm)(2));
  812. mesh.y= \&ym;        mptr= \&mesh;
  813. print, mesh.x(2,1:10), mptr->y(2,1:10);
  814. \endexample
  815.  
  816. \section{Index Range Functions}
  817.  
  818. Range functions are executed from left to right if more than one
  819. appears in a single index list.  The following range functions reduce
  820. the rank of the result, like a scalar index:
  821.  
  822. \beginindentedkeys
  823. \func{min}{minimum of values along index}
  824. \func{max}{maximum of values along index}
  825. \func{sum}{sum of values along index}
  826. \func{avg}{average of values along index}
  827. \func{rms}{root mean square of values along index}
  828. \func{ptp}{peak-to-peak of values along index}
  829. \func{mnx}{index at which minimum occurs}
  830. \func{mxx}{index at which maximum occurs}
  831. \endindentedkeys
  832.  
  833. The following functions do not change the rank of the result, like an
  834. index range.  However, the length of the index is changed as indicated
  835. by +1, -1, or 0 (no change):
  836.  
  837. \beginindentedkeys
  838. \func{cum, psum}{+1, 0, partial sums of values along index}
  839. \func{dif}{-1, pairwise differences of adjacent values}
  840. \func{zcen}{-1, pairwise averages of adjacent values}
  841. \func{pcen}{+1, pairwise averages of adjacent interior values}
  842. \func{uncp}{-1, inverse of pcen (point center) operation}
  843. \endindentedkeys
  844.  
  845. For example, given a two-dimensional array \kbd{x}, \kbd{x(min, max)}
  846. returns the largest of the smallest elements along the first dimension.
  847. To get the smallest of the largest elements along the second dimension,
  848. use \kbd{x(, max)(min)}.
  849.  
  850. \section{Elementary Functions}
  851.  
  852. \func{abs, sign}{absolute value, arithmetic sign}
  853. \func{sqrt}{square root}
  854. \func{floor, ceil}{round down, round up to integer}
  855. \func{conj}{complex conjugation}
  856. \func{pi}{the constant 3.14159265358979323846...}
  857. \func{sin, cos, tan}{trigonometric functions (of radians)}
  858. \func{asin, acos, atan}{inverse trigonometric functions}
  859. \func{sinh, cosh, tanh, sech, csch}{hyperbolic functions}
  860. \func{asinh, acosh, atanh}{inverse hyperbolic functions}
  861. \func{exp, log, log10}{exponential and logarithmic functions}
  862. \func{min, max}{find minimum, maximum of array}
  863. \func{sum, avg}{find sum, average of array}
  864. \func{random}{random number generator}
  865.  
  866. The \kbd{atan} function takes one or two arguments; \kbd{atan(t)}
  867. returns a value in the range $(-\pi/2,\pi/2])$, while \kbd{atan(y,x)}
  868. returns the counterclockwise angle from $(1,0)$ to $(x,y)$ in the
  869. range $(-\pi,\pi])$.
  870.  
  871. The \kbd{abs} function allows any number of arguments; for example,
  872. \kbd{abs(x, y, z)} is the same as \kbd{sqrt(x\^{}2 + y\^{}2 + z\^{}2)}.
  873. The \kbd{sign} satisfies \kbd{sign(0)==1} and \kbd{abs(z)*sign(z)==z}
  874. always (even when \kbd{z} is \kbd{complex}).
  875.  
  876. The \kbd{min} and \kbd{max} functions return a scalar result when
  877. presented with a single argument, but the pointwise minimum or maximum
  878. when presented with multiple arguments.
  879.  
  880. The \kbd{min}, \kbd{max}, \kbd{sum}, and single argument \kbd{abs}
  881. functions return integer results when presented integer arguments; the
  882. other functions will promote their arguments to a real type and return
  883. reals.
  884.  
  885. \section{Information About Variables}
  886.  
  887. \func{print, {\it var1, var2, ...}}{print the values of the {\it varI}}
  888. \func{info, {\it var}}{print a description of {\it var}}
  889. \func{dimsof({\it x\/})}{returns [\# dimensions, length1, length2, ...]}
  890. \func{orgsof({\it x\/})}{returns [\# dimensions, origin1, origin2, ...]}
  891. \func{numberof({\it x\/})}
  892.      {returns number of elements (product of \kbd{dimsof})}
  893. \func{typeof({\it x\/})}{returns name of data type of {\it x}}
  894. \func{structof({\it x\/})}{returns data type of {\it x}}
  895.  
  896. \func{is_array({\it x\/})}{returns 1 if {\it x} is an array, else 0}
  897. \func{is_func({\it x\/})}{returns 1 or 2 if {\it x} is an function, else 0}
  898. \func{is_void({\it x\/})}{returns 1 if {\it x} is nil, else 0}
  899. \func{is_range({\it x\/})}{returns 1 if {\it x} is an index range, else 0}
  900. \func{is_stream({\it x\/})}{returns 1 if {\it x} is a binary file, else 0}
  901. \func{am_subroutine()}{1 if current function invoked as subroutine}
  902.  
  903. The \kbd{print} function returns a string array of one string per line if
  904. it is invoked as a function.  Using \kbd{print} on files, bookmarks, and
  905. other objects usually produces some sort of useful description.  Also,
  906. \kbd{print} is the default function, so that
  907. \begindemo
  908. \hglue2em{\it expr}
  909. \enddemo
  910.  
  911. is equivalent to \kbd{print,} {\it expr\/} (if {\it expr\/} is not a function).
  912.  
  913. \section{Reshaping Arrays}
  914.  
  915. \func{reshape, {\it x, type\_name, dimlist}}
  916.      {masks shape of {\it x}}
  917.  
  918. Don't try to use this unless (1) you're an expert, and (2) you're desperate.
  919. It is intended mainly for recovering from misfeatures of other programs,
  920. although there are a few legitimate uses within Yorick.
  921.  
  922. \section{Logical Functions}
  923.  
  924. \func{allof({\it x\/})}{returns 1 if every element of {\it x} is non-zero}
  925. \func{anyof({\it x\/})}{returns 1 if any element of {\it x} is non-zero}
  926. \func{noneof({\it x\/})}{returns 1 if no element of {\it x} is non-zero}
  927. \func{nallof({\it x\/})}{returns 1 if any element of {\it x} is zero}
  928.  
  929. \func{where({\it x\/})}{returns list of indices where {\it x} is non-zero}
  930. \func{where2({\it x\/})}{human-readable variant of \kbd{where}}
  931.  
  932. \section{Interpolation and Lookup Functions}
  933.  
  934. In the following function, {\it y\/} and {\it x\/} are one-dimensional
  935. arrays which determine a piecewise linear function {\it y(x)}.  The {\it x\/}
  936. must be monotonic.  The {\it xp\/} (for {\it x\/}-prime) can be an
  937. array of any dimensionality; the dimensions of the result will be the
  938. same as the dimensions of {\it xp}.
  939.  
  940. \func{digitize({\it xp, x\/})}
  941.      {returns indices of {\it xp\/} values in {\it x}}
  942. \func{interp({\it y, x, xp\/})}
  943.      {returns {\it yp}, {\it xp\/} interpolated into {\it y(x)}}
  944. \func{integ({\it y, x, xp\/})}
  945.      {returns the integrals of {\it y(x)\/} from {\it x\/}(1) to {\it xp}}
  946.  
  947. Note that \kbd{integ} is really an area-conserving interpolator.  If
  948. the {\it xp} coincide with {\it x}, you probably want to use \hfil\break
  949. \hglue2em \kbd{(}{\it y\/}\kbd{(zcen)*}{\it x\/}\kbd{(dif))(cum)} \hfil\break
  950. instead.
  951.  
  952. The on-line \kbd{help} documentation for \kbd{interp} describes how to
  953. use \kbd{interp} and \kbd{integ} with multidimensional {\it y} arrays.
  954.  
  955. \section{Sorting}
  956.  
  957. \func{sort({\it x\/})}{return index list which sorts {\it x}}
  958.  
  959. That is, {\it x\/}\kbd{(sort({\it x\/}))} will be in non-decreasing order
  960. ({\it x\/} can be an integer, real, or string array).  The on-line
  961. \kbd{help} documentation for \kbd{sort} explains how to sort
  962. multidimensional arrays.
  963.  
  964. \func{median({\it x\/})}{return the median of the {\it x\/} array}
  965.  
  966. Consult the on-line \kbd{help} documentation for \kbd{median} for use
  967. with multidimensional arrays.
  968.  
  969. \section{Transposing}
  970.  
  971. \func{transpose({\it x\/})}{transpose the 2-D array {\it x}}
  972. \func{transpose({\it x, permutation\/})}{general transpose}
  973.  
  974. The {\it permutation\/} is a comma delimited list of cyclic permutations
  975. to be applied to the indices of {\it x}.  Each cyclic permutation may
  976. be:
  977.  
  978. \hangindent=1em
  979. \hangafter=1
  980. $\bullet$ a list of dimension numbers [{\it n1, n2, ..., nN\/}] \hfil\break
  981. to move dimension number {\it n1\/} (the first dimension is number 1, the
  982. second number 2, and so on) to dimension number {\it n2\/}, {\it n2\/} to
  983. {\it n3\/}, and so on, until finally {\it nN\/} is moved to {\it n1\/}.
  984.  
  985. \hangindent=1em
  986. \hangafter=1
  987. $\bullet$ a scalar integer {\it n} \hfil\break
  988. to move dimension number 1 to dimension number {\it n\/}, 2 to {\it n\/}+1,
  989. and so on, cyclically permuting all of the indices of {\it x}.
  990.  
  991. In either case, {\it n\/} or {\it nI\/} can be non-positive to refer to
  992. indices relative to the {\bf final} dimension of {\it x}.  That is, 0 refers
  993. to the final dimension of {\it x}, -1 to the next to last dimension, and so
  994. on.  Thus, \hfil\break
  995. \hglue2em \kbd{transpose({\it x}, [1,0])} \hfil\break
  996. swaps the first and last dimensions of {\it x}.
  997.  
  998. \section{Manipulating Strings}
  999.  
  1000. Yorick type \kbd{string} is a pointer to a 0-terminated
  1001. array of \kbd{char}.  A string with zero characters -- \kbd{""} -- differs
  1002. from a zero pointer -- \kbd{string(0)}.  A \kbd{string} variable {\it s\/}
  1003. can be converted to a \kbd{pointer} to a 1-D array of \kbd{char}, and such
  1004. a \kbd{pointer} {\it p\/} can be converted back to a \kbd{string}:
  1005. \begindemo
  1006. \hglue2em \kbd{{\it p\/}= pointer({\it s\/});}
  1007. \hglue2em \kbd{{\it s\/}= string({\it p\/});}
  1008. \enddemo
  1009. These conversions copy the characters, so you can't use the pointer {\it p\/}
  1010. to alter the characters of {\it s}.
  1011.  
  1012. Given a string or an array of strings {\it s\/}:
  1013.  
  1014. \func{strlen({\it s\/})}{number of characters in each element of {\it s\/}}
  1015. \func{strmatch({\it s, pat\/})}{1 if {\it pat} occurs in {\it s\/}}
  1016. \func{strmatch({\it s, pat}, 1)}
  1017.      {1 if {\it pat} occurs in {\it s\/}, case insensitive}
  1018. \func{strpart({\it s, m:n\/})}{returns substring of {\it s\/}}
  1019. \func{strtok({\it s, delims\/})}{gets first token of {\it s}}
  1020. \func{strtok({\it s\/})}{gets first whitespace delimited token of {\it s}}
  1021.  
  1022. The \kbd{strtok} function returns a 2-by-\kbd{dimsof({\it s\/})} array of
  1023. strings --- the first token followed by the remainder of the string.  The
  1024. token will be \kbd{string(0)} if no tokens were present; the remainder of
  1025. string will be \kbd{string(0)} if there are no characters after the token.
  1026.  
  1027. \section{Advanced Array Indexing}
  1028.  
  1029. \hangindent=1em
  1030. \hangafter=1
  1031. $\bullet$ A scalar index or the \kbd{start} and \kbd{stop} of an index
  1032. range may be non-positive to reference the elements near the end of a
  1033. dimension.  Hence, 0 refers to the final element, -1 refers to the next
  1034. to last element, -2 to the element before that, and so on.  For example,
  1035. {\it x\/}\kbd{(2:-1)} refers to all but the first and last elements of
  1036. the 1-D array {\it x}.  This convention does {\bf NOT} work for an index
  1037. list.
  1038.  
  1039. \hangindent=1em
  1040. \hangafter=1
  1041. $\bullet$ A range function {\it ifunc} may be followed by a colon and an
  1042. index range \kbd{start:stop} or \kbd{start:stop:step} in order to restrict
  1043. the indices to which the range function applies to a subset of the entire
  1044. dimension.  Hence, {\it x\/}\kbd{(min:2:-1)} returns the minimum of all
  1045. the elements of the 1-D array {\it x}, excluding the first and last elements.
  1046.  
  1047. \hangindent=1em
  1048. \hangafter=1
  1049. $\bullet$ An index specified as a scalar, the \kbd{start} or \kbd{stop} of
  1050. an index range, or an element of an index list may exceed the length of the
  1051. indexed dimension {\bf ID}, provided that the entire indexing operation does
  1052. not overreach the bounds of the array.  Thus, if {\it y\/} is a 5-by-6 array,
  1053. then {\it y\/}\kbd{(22)} refers to the same datum as  {\it y\/}\kbd{(2,5)}.
  1054.  
  1055. \hangindent=1em
  1056. \hangafter=1
  1057. $\bullet$ The expression {\it z\/}\kbd{(..)} --- using the rubber-index
  1058. operator \kbd{..} --- refers to the entire array {\it z\/}.  This is
  1059. occasionally useful as the left hand side of an assignment statement in
  1060. order to force broadcasting and type conversion of the right hand
  1061. expression to the preallocated type and shape {\it z\/}.
  1062.  
  1063. \hangindent=1em
  1064. \hangafter=1
  1065. $\bullet$ The expression {\it z\/}\kbd{(*)} --- using the rubber-index
  1066. operator \kbd{*} --- collapses a multidimensional array {\it z\/} into
  1067. a one-dimensional array.  Even more useful as {\it z\/}\kbd{(*,)} to
  1068. preserve the final index of an array and force a two-dimensional result.
  1069.  
  1070. \section{Generating Simple Meshes}
  1071.  
  1072. Many Yorick calculations begin by defining an array of {\it x\/} values
  1073. which will be used as the argument to functions of a single variable.
  1074. The easiest way to do this is with the \kbd{span} or \kbd{spanl} function:
  1075. \begindemo
  1076. \hglue2em \kbd{x= span(x\_min, x\_max, 200);}
  1077. \enddemo
  1078. This gives 200 points equally spaced from \kbd{x\_min} to \kbd{x\_max}.
  1079.  
  1080. A two dimensional rectangular grid is most easily obtained as follows:
  1081. \begindemo
  1082. \hglue1em \kbd{x= span(x\_min, x\_max, 50)(, -:1:40);}
  1083. \hglue1em \kbd{y= span(y\_min, y\_max, 40)(-:1:50, );}
  1084. \enddemo
  1085. This gives a 50-by-40 rectangular grid with \kbd{x} varying fastest.
  1086. Such a grid is appropriate for exploring the behavior of a function of
  1087. two variables.  Higher dimensional meshes can be built in this way, too.
  1088.  
  1089. \copyrightnotice
  1090.  
  1091. \par\vfill\supereject
  1092.  
  1093. %----------------------------------------------------------------------------
  1094.  
  1095. \title{Yorick I/O Reference}
  1096.  
  1097. \centerline{(for version 1)}
  1098.  
  1099. \section{Opening and Closing Text Files}
  1100.  
  1101. \func{{\it f\/}= open({\it filename, mode\/})}
  1102.      {open {\it filename\/} in {\it mode}}
  1103. \func{close, {\it f}}
  1104.      {close file {\it f} (automatic if {\it f\/} redefined)}
  1105.  
  1106. The {\it mode} is a string which announces the type of operations you
  1107. intend to perform: \kbd{"r"} (the default if {\it mode\/} is omitted)
  1108. means read operations only, \kbd{"w"} means write only, and destroy any
  1109. existing file {\it filename}, \kbd{"r+"} means read/write, leaving any
  1110. existing file {\it filename\/} intact.  Other {\it mode\/} values are
  1111. also meaningful; see \kbd{help}.
  1112.  
  1113. The file variable {\it f\/} is a distinct data type in Yorick; text
  1114. files have a different data type than binary files.  The \kbd{print}
  1115. or \kbd{info} function will describe the file.  The \kbd{close}
  1116. function is called implicitly when the last reference to a file disappears.
  1117.  
  1118. \section{Reading Text}
  1119.  
  1120. \func{read, {\it f, var1, var2, ..., varN}}
  1121.      {reads the {\it varI} from file {\it f}}
  1122. \func{read, {\it var1, var2, ..., varN}}
  1123.      {reads the {\it varI\/} from keyboard}
  1124. \func{read\_n, {\it f, var1, var2, ..., varN}}
  1125.      {read, skip non-numeric tokens}
  1126. \func{rdline({\it f\/})}
  1127.      {returns next line from file {\it f}}
  1128. \func{rdline({\it f, n\/})}
  1129.      {returns next {\it n\/} lines from file {\it f}}
  1130. \func{sread, {\it s, var1, var2, ..., varN}}
  1131.      {reads the {\it varI\/} from string {\it s}}
  1132.  
  1133. The data type and dimensions of the {\it varI\/} determine how the text
  1134. is converted as it is read.  The {\it varI\/} may be arrays, provided the
  1135. arrays have identical dimensions.  If the {\it varI\/} have length {\bf L},
  1136. then the \kbd{read} is applied as if  called {\bf L} times, with successive
  1137. elements of each of the {\it varI\/} read on each call.
  1138.  
  1139. The \kbd{read} function takes the \kbd{prompt} keyword to set the prompt
  1140. string, which defaults to \kbd{"read> "}.
  1141.  
  1142. Both \kbd{read} and \kbd{sread} accept the \kbd{format} keyword.  The
  1143. format is a string containing conversion specifiers for the {\it varI}.
  1144. The number of conversion specifiers should match the number of {\it varI}.
  1145. If the {\it varI\/} are arrays, the format string is applied repeatedly
  1146. until the arrays are filled.
  1147.  
  1148. Read format strings in Yorick have (nearly) the same meaning as the
  1149. format strings for the ANSI standard C library \kbd{scanf} routine.  In
  1150. brief, a format string consists of:
  1151.  
  1152. \hangindent=1em
  1153. \hangafter=1
  1154. $\bullet$ whitespace \hfil\break
  1155. means to skip any number of whitespace characters in the source
  1156.  
  1157. \hangindent=1em
  1158. \hangafter=1
  1159. $\bullet$ characters other than whitespace and \kbd{\%} \hfil\break
  1160. must match characters in the source exactly or the read operation stops
  1161.  
  1162. \hangindent=1em
  1163. \hangafter=1
  1164. $\bullet$ conversion specifiers beginning with \kbd{\%} \hfil\break
  1165. each specifier ends with one of the characters \kbd{d} (decimal integer),
  1166. \kbd{i} (decimal, octal, or hex integer), \kbd{o} (octal integer),
  1167. \kbd{x} (hex integer), \kbd{s} (whitespace delimited string),
  1168. any of \kbd{e}, \kbd{f}, or \kbd{g} (real),
  1169. \kbd{[{\it xxx}]} to match the longest string of characters in the list,
  1170. \kbd{[\^{}{\it xxx}]} to match the longest string of characters not in
  1171. the list, or \kbd{\%} (the \kbd{\%} character -- not a conversion)
  1172.  
  1173. \shortcopyrightnotice
  1174.  
  1175. \section{Writing Text}
  1176.  
  1177. \func{write, {\it f, expr1, expr2, .., exprN}}
  1178.      {writes the {\it exprI\/} to file {\it f}}
  1179. \func{write, {\it expr1, expr2, .., exprN}}
  1180.      {writes the {\it exprI\/} to terminal}
  1181. \func{swrite({\it expr1, expr2, .., exprN\/})}
  1182.      {returns the {\it exprI\/} as a string}
  1183.  
  1184. The \kbd{swrite} function returns an array of strings --- one string
  1185. for each line that would have been produced by the \kbd{write} function.
  1186.  
  1187. The {\it exprI\/} may be arrays, provided the arrays are conformable.
  1188. In this case, the {\it exprI\/} are broadcast to the same length {\bf L},
  1189. then the \kbd{write} is applied as if called {\bf L} times, with
  1190. successive elements of the {\it exprI\/} written on each call.
  1191.  
  1192. Both functions accept an optional \kbd{format} keyword.  Write format
  1193. strings in Yorick have (nearly) the same meaning as the format strings
  1194. for the ANSI stacndard C library \kbd{printf} routine.  In brief, a format
  1195. string consists of:
  1196.  
  1197. \hangindent=1em
  1198. \hangafter=1
  1199. $\bullet$ characters other than \kbd{\%} \hfil\break
  1200. which are copied directly to output
  1201.  
  1202. \hangindent=1em
  1203. \hangafter=1
  1204. $\bullet$ conversion specifiers beginning with \kbd{\%} \hfil\break
  1205. of the general format \kbd{\%}{\it FW.PSC\/} where: \hfil\break
  1206. {\it F\/} is zero or more of the optional flags \kbd{-} (left justify),
  1207. \kbd{+} (always print sign), (space) (leave space if +), \kbd{0}
  1208. (leading zeroes) \hfil\break
  1209. {\it W\/} is an optional decimal integer specifying the minimum number
  1210. of characters to output \hfil\break
  1211. {\it .P\/} is an optional decimal integer specifying the number of
  1212. digits of precision \hfil\break
  1213. {\it S\/} is one of \kbd{h}, \kbd{l}, or \kbd{L}, ignored by Yorick \hfil\break
  1214. {\it C\/} is \kbd{d} or \kbd{i} (decimal integer), \kbd{o} (octal integer),
  1215. \kbd{x} (hex integer), \kbd{f} (fixed point real), \kbd{e} (scientific
  1216. real), \kbd{g} (fixed or scientific real), \kbd{s} (string), \kbd{c}
  1217. (ASCII character), or \kbd{\%} (the \kbd{\%} character -- not a conversion)
  1218.  
  1219. For example,
  1220. \beginexample
  1221. > write, format="   tp \%7.4f \%e\\n", [1.,2.], [.5,.6]
  1222.    tp  1.0000 5.000000e-01
  1223.    tp  2.0000 6.000000e-01
  1224. >
  1225. \endexample
  1226.  
  1227. \section{Positioning a Text File}
  1228.  
  1229. The \kbd{write} function always appends to the end of a file.
  1230.  
  1231. A sequence of \kbd{read} operations may be intermixed with \kbd{write}
  1232. operations on the same file.  The two types of operations do not
  1233. interact.
  1234.  
  1235. The \kbd{read} and \kbd{rdline} functions read the file in complete
  1236. lines; a file cannot be positioned in the middle of a line -- although
  1237. the \kbd{read} function may ignore a part of the last line read,
  1238. subsequent \kbd{read} operations will begin with the next full line.
  1239. The following functions allow the file to be reset to a previously
  1240. read line.
  1241.  
  1242. \func{backup, {\it f}}{back up file {\it f\/} one line}
  1243. \func{{\it m\/}= bookmark({\it f\/})}
  1244.      {record position of file {\it f\/} in {\it m}}
  1245. \func{backup, {\it f}, {\it m}}{back up file {\it f\/} to {\it m}}
  1246.  
  1247. The bookmark {\it m\/} records the current position of the file; it
  1248. has a distinct Yorick data type, and the \kbd{info} or \kbd{print}
  1249. function can be used to examine it.  Without a bookmark, the \kbd{backup}
  1250. function can back up only a single line.
  1251.  
  1252. \section{Opening and Closing Binary Files}
  1253.  
  1254. \func{{\it f\/}= openb({\it filename\/})}
  1255.      {open {\it filename\/} read-only}
  1256. \func{{\it f\/}= updateb({\it filename\/})}
  1257.      {open {\it filename\/} read-write}
  1258. \func{{\it f\/}= createb({\it filename\/})}
  1259.      {create the binary file {\it filename\/}}
  1260. \func{close, {\it f}}
  1261.      {close file {\it f}}
  1262.  
  1263. A binary file {\it f\/} has a Yorick data type which is distinct from a text
  1264. file.  The \kbd{info} and \kbd{print} functions describe {\it f\/}.  The
  1265. \kbd{close} function will be called implicitly when the last reference to
  1266. a file disappears, e.g.-- if {\it f} is redefined.
  1267.  
  1268. The data in a binary file is organized into named variables, each of
  1269. which has a data type and dimensions.  The \kbd{.} operator, which extracts
  1270. members from a structure instance, accepts binary files for its left
  1271. operand.  Thus:
  1272. \beginexample
  1273. \hglue2em f= updateb("foo.bar");
  1274. \hglue2em print, f.var1, f.var2(2:8,::4);
  1275. \hglue2em f.var3(2,5)= 3.14;
  1276. \hglue2em close, f;
  1277. \endexample
  1278. Opens a file, prints \kbd{var1} and a subarray of \kbd{var2}, sets one
  1279. element of \kbd{var3}, then closes the file.
  1280.  
  1281. The \kbd{show} command prints an alphabetical list of the variables
  1282. contained in a file:
  1283.  
  1284. \func{show, {\it f}}{shows the variables in file {\it f}}
  1285. \func{show, {\it f, pat}}{show only names starting with {\it pat}}
  1286. \func{get_vars({\it f\/})}
  1287.      {returns pointers to complete name lists for {\it f}}
  1288.  
  1289. \section{Saving and Restoring Variables}
  1290.  
  1291. \func{save, {\it f, var1, var2, ..., varN}}
  1292.      {saves the {\it varI\/} in binary file {\it f}}
  1293. \func{restore, {\it f, var1, var2, ..., varN}}
  1294.      {restores the {\it varI\/} from {\it f}}
  1295. \func{save, {\it f}}
  1296.      {saves all array variables in binary file {\it f}}
  1297. \func{restore, {\it f}}
  1298.      {restores all variables from binary file {\it f}}
  1299.  
  1300. Unlike {\it f.varI\/}\kbd{=} {\it expr}, the \kbd{save} function will
  1301. create the variable {\it varI\/} in the file {\it f\/} if it does not
  1302. already exist.
  1303.  
  1304. The \kbd{restore} function redefines the in-memory
  1305. {\it varI\/}.  If several binary
  1306. files are open simultaneously, the {\it f.varI\/} syntax will be more
  1307. useful for reading variables than the \kbd{restore} function.
  1308.  
  1309. Note that a single command can be used to create a binary file, save
  1310. variables {\it varI\/} in it, and close the file:
  1311. \beginexample
  1312. \hglue2em save, createb({\it filename\/}), {\it var1, var2, ..., varN}
  1313. \endexample
  1314. A similar construction using \kbd{restore} and \kbd{openb} is also useful.
  1315.  
  1316. \section{Reading History Records}
  1317.  
  1318. A binary file may have two groups of variables: those belonging to a set
  1319. of history records, and non-record variables.
  1320. The record variables may have different values in each record.  The records
  1321. are labeled by (optional) time and cycle numbers:
  1322.  
  1323. \func{jt, {\it time}}
  1324.      {advance all open record files to record nearest {\it time}}
  1325. \func{jt, {\it f, time}}
  1326.      {advance file {\it f\/} to record nearest {\it time}}
  1327. \func{jc, {\it f, ncyc}}
  1328.      {advance file {\it f\/} to record nearest {\it ncyc}}
  1329. \func{get\_times({\it f\/})}{return list of record times}
  1330. \func{get\_ncycs({\it f\/})}{return list of record cycles}
  1331.  
  1332. \section{Writing History Records}
  1333.  
  1334. To write a family of files containing history records:
  1335.  
  1336. \hangindent=1em
  1337. \hangafter=1
  1338. 1.\hglue.5emCreate the file using \kbd{createb}.
  1339.  
  1340. \hangindent=1em
  1341. \hangafter=1
  1342. 2.\hglue.5emWrite all of the non-record (time independent) variables to the
  1343. file using \kbd{save}.
  1344.  
  1345. \hangindent=1em
  1346. \hangafter=1
  1347. 3.\hglue.5emCreate a record which will correspond to time {\it time} and cycle
  1348. {\it ncyc} for future \kbd{jt} and \kbd{jc} commands.  Use:
  1349.  
  1350. \func{add_record, {\it f, time, ncyc}}{make new record at {\it time, ncyc}}
  1351.  
  1352. \hangindent=1em
  1353. \hangafter=1
  1354. 4.\hglue.5emWrite all record (time dependent) variables to the file using
  1355. \kbd{save}.  After the first \kbd{add_record}, \kbd{save} will create and
  1356. store record variables instead of non-record variables as in step 2.
  1357.  
  1358. \hangindent=1em
  1359. \hangafter=1
  1360. 5.\hglue.5emRepeat steps 3 and 4 for each new record you wish to add to the
  1361. file.  For the second and subsequent records, \kbd{save} will not allow
  1362. variables which were not written to the first record, or whose data type or
  1363. shape has changed since the first record.  That is, the structure of all
  1364. history records in a file must be identical.  Use type \kbd{pointer} variables
  1365. to deal with data which changes in size, shape, or data type.
  1366.  
  1367. After each \kbd{add\_record}, any number of \kbd{save} commands may be used
  1368. to write the record.
  1369.  
  1370. If the current member of a history record file family has at least one
  1371. record, and if the next record would cause the file to exceed the maximum
  1372. allowed file size, \kbd{add_record} will automatically form the next member
  1373. of the family.  The maximum family member file size defaults to 4 MBytes, but:
  1374.  
  1375. \func{set\_filesize, {\it f, n\_bytes}}{set family member size}
  1376.  
  1377. \section{Opening Non-PDB Files}
  1378.  
  1379. Yorick expects binary files to be in PDB format, but it can be trained to
  1380. recognize any file whose format can be described using its Contents Log
  1381. file description language.  The basic idea is that if you can figure out
  1382. how to compute the names, data types, dimensions, and disk addresses of the
  1383. data in the file, you can train Yorick to open the file; once open, all of
  1384. Yorick's machinery to manipulate the data will grind away as usual.
  1385.  
  1386. The following functions can be used to teach Yorick about a non-PDB file;
  1387. use \kbd{help} to get complete details:
  1388.  
  1389. \func{\_read, {\it f, address, var}}{raw binary read}
  1390. \func{install\_struct, {\it f, struct\_name, size, align, order, layout}}{}
  1391. \func{}{define a primitive data type}
  1392. \func{add_variable, {\it f, address, name, type, dimlist}}
  1393.      {add a variable}
  1394. \func{add_member, {\it f, struct\_name, offset, name, type, dimlist}}{}
  1395. \func{}{build up a data structure}
  1396. \func{install\_struct, {\it f, struct\_name}}{finish \kbd{add_member} struct}
  1397. \func{data\_align, {\it f, alignment}}{specify default data alignment}
  1398. \func{struct\_align, {\it f, alignment}}{specify default struct alignment}
  1399. \func{add\_record, {\it f, time, ncyc, address}}{declare record}
  1400. \func{add\_next\_file, {\it f, filename}}{open new family member}
  1401.  
  1402. To write a plain text description of any binary file, use:
  1403.  
  1404. \func{dump\_clog, {\it f, clogname}}{write Contents Log for {\it f}}
  1405.  
  1406. \section{Making Plots}
  1407.  
  1408. \func{plg, {\it y, x}}{plot graph of 1-D {\it y} vs.\ {\it x}}
  1409. \func{plm, {\it mesh\_args}}{plot quadrilateral mesh}
  1410. \func{plc, {\it z, mesh\_args}}{plot contours of {\it z}}
  1411. \func{plf, {\it z, mesh\_args}}{plot filled mesh, filling with {\it z}}
  1412. \func{plv, {\it v, u, mesh\_args}}{plot vector field ({\it u,v)\/})}
  1413. \func{pli, {\it z, x0, y0, x1, y1}}{plot image {\it z}}
  1414. \func{pldj, {\it x0, y0, x1, y1}}{plot disjoint lines}
  1415. \func{plt, {\it text, x, y}}{plot {\it text\/} at ({\it x,y\/})}
  1416.  
  1417. The {\it mesh\_args\/} may be zero, two, or three arguments as follows:
  1418.  
  1419. \hangindent=1em
  1420. \hangafter=1
  1421. $\bullet$ omitted to use the current default mesh set by:
  1422.  
  1423. \func{plmesh, {\it mesh\_args}}{set default quadrilateral mesh}
  1424. \func{plmesh}{delete current default quadrilateral mesh}
  1425.  
  1426. \hangindent=1em
  1427. \hangafter=1
  1428. $\bullet$ {\it y, x} \hfil\break
  1429. To set mesh points to ({\it x, y\/}), which must be 2-D arrays of the same
  1430. shape, with at least two elements in each dimension.
  1431.  
  1432. \hangindent=1em
  1433. \hangafter=1
  1434. $\bullet$ {\it y, x, ireg} \hfil\break
  1435. To set mesh points to ({\it x, y\/}), as above, with a region number array
  1436. {\it ireg}.  The {\it ireg\/} should be an integer array of the same
  1437. shape as {\it y\/} and {\it x}, which has a non-zero ``region number'' for
  1438. every meaningful zone in the problem.  The first row and column of
  1439. {\it ireg\/} do not correspond to any zone, since there are one fewer zones
  1440. along each dimension than points in {\it y\/} and {\it x}.
  1441.  
  1442. The \kbd{plc} command accepts the \kbd{levs} keyword to specify the list of
  1443. {\it z\/} values to be contoured; by default, eight linearly spaced levels
  1444. are generated.
  1445.  
  1446. The \kbd{plc} and \kbd{plmesh} commands accept the \kbd{triangle} keyword
  1447. to specify a detailed triangulation map for the contouring algorithm.  Use
  1448. the \kbd{help, triangle} for details.
  1449.  
  1450. The \kbd{plv} command accepts the \kbd{scale} keyword to specify the
  1451. scaling factor to be applied to ({\it u, v\/}) before rendering the vectors
  1452. in ({\it x, y\/}) space; by default, the vector lengths are chosen to be
  1453. comparable to typical zone dimensions.
  1454.  
  1455. The \kbd{plm} command accepts the \kbd{boundary} keyword, which should be
  1456. set to 1 if only the mesh boundary, rather than the mesh interior, is to
  1457. be plotted.
  1458.  
  1459. The \kbd{plm}, \kbd{plc}, \kbd{plf}, and \kbd{plv} commands accept the
  1460. \kbd{region} keyword to restrict the plot to only one region of the
  1461. mesh, as numbered by the {\it ireg\/} argument.  The default \kbd{region}
  1462. is 0, which is interpreted to mean the every non-0 region of the mesh.
  1463.  
  1464. The \kbd{pli} command produces a cell array; the {\it x0, y0, x1, y1\/},
  1465. which are optional, specify the coordinates of the opposite corners of the
  1466. cell array.
  1467.  
  1468. Numerous other keywords adjust the style of lines, text, etc.
  1469.  
  1470. \section{Plot Paging and Hardcopy}
  1471.  
  1472. \func{fma}{frame advance --- next plot command will clear picture}
  1473. \func{hcp}{send current picture to hardcopy file}
  1474. \func{hcpon}{do automatic \kbd{hcp} at each \kbd{fma}}
  1475. \func{hcpoff}{require explicit \kbd{hcp} for hardcopy}
  1476. \func{hcp\_out}{print and destroy current hardcopy file}
  1477. \func{animate}{toggle animation mode (see \kbd{help})}
  1478.  
  1479. \section{Setting Plot Limits}
  1480.  
  1481. \func{logxy, {\it xflag, yflag}}{set log or linear axis scaling}
  1482.  
  1483. \func{limits, {\it xmin, xmax, ymin, ymax}}{set plot limits}
  1484. \func{limits, {\it xmin, xmax}}{set plot x-limits}
  1485. \func{range, {\it ymin, ymax}}{set plot y-limits}
  1486. \func{{\it l\/}= limits()}{save current plot limits in {\it l\/}}
  1487. \func{limits, {\it l}}{restore plot limits saved in {\it l\/}}
  1488.  
  1489. The four plot limits can be numbers to fix them at specific values, or
  1490. the string \kbd{"e"} to specify extreme values.  The \kbd{limits}
  1491. command accepts the keywords \kbd{square}, \kbd{nice}, and
  1492. \kbd{restrict}, which control how extreme values are computed.
  1493.  
  1494. Plot limits may also be set by point-and-click in the X window.  The
  1495. left button zooms in, middle button pans, and right button zooms out.
  1496. Refer \kbd{help} on \kbd{limits} for details.
  1497.  
  1498. \section{Managing Graphics Windows}
  1499.  
  1500. \func{window, {\it n}}{switch to window {\it n\/} (0-7)}
  1501. \func{winkill, {\it n}}{delete window {\it n\/} (0-7)}
  1502.  
  1503. The \kbd{window} command takes several keywords, for example:
  1504. \kbd{dpi=75} makes a smaller X window than the default \kbd{dpi=100},
  1505. \kbd{private=1} forces use of private instead of shared colors,
  1506. \kbd{dump=1} forces the palette to be dumped to the \kbd{hcp} file,
  1507. and \kbd{style} specifies an alternative style sheet for
  1508. tick and label style (\kbd{"work.gs"} and \kbd{"boxed.gs"} are two
  1509. predefined style sheets).
  1510.  
  1511. The \kbd{plf} and \kbd{pli} commands require a color palette:
  1512.  
  1513. \func{palette, {\it name}}{load the standard palette {\it name}}
  1514. \func{palette, {\it r, g, b}}{load a custom palette}
  1515. \func{palette, query=1, {\it r, g, b}}{retrieve current palette}
  1516.  
  1517. Standard palette names: \kbd{"earth.gp"} (the default), \kbd{"gray.gp"},
  1518. \kbd{"yarg.gp"}, \kbd{"stern.gp"}, \kbd{"heat.gp"}, and \kbd{"rainbow.gp"}.
  1519.  
  1520. \section{Graphics Query, Edit, and Defaults}
  1521.  
  1522. \func{plq}{query (print) legends for current window}
  1523. \func{plq, {\it i}}{query properties of element {\it i}}
  1524. \func{pledit, {\it key\_list}}{change properties of queried element}
  1525. \func{pldefault, {\it key\_list}}{set default window and element properties}
  1526.  
  1527. The keywords which regulate the appearance of graphical primitives
  1528. include (each has a \kbd{help} entry):
  1529.  
  1530. \func{legend}{string to use for legend}
  1531. \func{hide}{non-zero to skip element}
  1532. \func{type}{\kbd{"solid", "dash", "dot", "dashdot"}, etc.}
  1533. \func{width}{line width, default 1.0}
  1534. \func{color}{\kbd{"fg"} (default), \kbd{"red", "green", "blue"}, etc.}
  1535. \func{marks, marker, mspace, mphase, msize}{line markers}
  1536. \func{rays, rspace, rphase, arroww, arrowl}{line ray arrows}
  1537. \func{closed, smooth}{more line properties}
  1538. \func{font, height, opaque, path, justify}{text properties}
  1539. \func{hollow, aspect}{vector properties for \kbd{plv}}
  1540.  
  1541. \copyrightnotice
  1542.  
  1543. \bye
  1544.  
  1545. % Local variables:
  1546. % compile-command: "tex refs"
  1547. % End:
  1548.