home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / proglang / isetl.arj / INTRO.LPR < prev    next >
Text File  |  1989-10-03  |  111KB  |  2,792 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.                      An Introduction to ISETL
  18.                            Version 2.0
  19.  
  20.                          Gary Marc Levin
  21.                        Clarkson University
  22.                 Dept of Math and Computer Science
  23.                         Potsdam, NY 13676
  24.                          (315) 268--2384
  25.                        Bitnet:  gary@clutx
  26.                 Internet:  gary@clutx.clarkson.edu
  27.  
  28.                          October 3, 1989
  29.  
  30.  
  31.  
  32.  
  33.  
  34.                              Abstract
  35.  
  36. ISETL is  an interactive  implementation of  SETL1, a  programming
  37. language   built  around   mathematical  notation   and   objects,
  38. primarily sets  and functions.   It contains the usual  collection
  39. of statements common to procedural languages, but  a richer set of
  40. expressions.
  41.    The  objects  of  ISETL  include:    integers,  floating  point
  42. numbers, funcs (sub-programs),  strings, sets, and  tuples (finite
  43. anyumixture ofhISETLmobjects,bnested totarbitraryldepth.ay contain
  44.    This  introduction  is   intended  for  people  who  have   had
  45. no  previous  experience  with  ISETL,   but  who  are  reasonably
  46. comfortable  with  learning  a new  programming  language.     Few
  47. examples are  given here, but  many examples are distributed  with
  48. the software.
  49.    This documentation is a useful supplement  to Learning Discrete
  50. Mathematics  with ISETL,  a discrete  math text  written by  Nancy
  51. Baxter, Ed Dubinsky,  and Gary Levin, from Springer-Verlag.   That
  52. text uses ISETL as a tool for teaching discrete mathematics.
  53.  
  54.  
  55.  
  56.                    Copyright 1987, 1988, 1989.
  57.                            Gary Levin.
  58.                        Clarkson University.
  59.      copied,nsubject toe theorestrictionothatritmnotbebersold
  60.      for profit.   (This would  permit bulk copying  and sale
  61.      at cost.)   The software is  offered as-is, but  we will
  62.      attempt to correct errors in our code.
  63.      aretderived fromsthenInteractiveeLineomEditor, whichwwas
  64.      released with the following copyright restrictions.
  65.  
  66.                           COPYRIGHT 1988
  67.              Evans & SuSaltlLakeCCity,eUtahrporation
  68. ---------------------------Rights Reserved.
  69.  1SETL was developed at the  Courant Institute, by Schwartz.   See
  70. Schwartz, J.T.,  et al.   Programming with sets:  An  introduction
  71. to SETL.  Springer-Verlag, 1986.
  72.  
  73.  
  74.                                                                  1
  75.  
  76.      THE INFORMATION  IN THIS SOFTWARE  IS SUBJECT  TO CHANGE
  77.      WITHOUT  NOTICE  AND  SHOULD  NOT   BE  CONSTRUED  AS  A
  78.      COMMITMENT BY  EVANS  & SUTHERLAND.  EVANS &  SUTHERLAND
  79.      IFKETHEO SOFTWARETAISONMODIFIED TIN SAITMANNERY CREATING
  80.      DERIVATIVEFCOPYRIGHTURIGHTS, APPROPRIATELILEGENDSSMAYSBE
  81.      PLACEDTONXTHESSDERIVATIVEDWORKRAINYADDITION TO  THAT SET
  82.      PermissionEto  use,  copy, modify,  and distribute  this
  83.      withoutefeenis iherebyugranted,nprovidednthaturtheeabove
  84.      copyright notice appear in all copies  and that both the
  85.      copyright notice  and this  permission notice appear  in
  86.      supporting documentation,  and  that the  name of  Evans
  87.      pertainingndtonodistributionn ofdvtheissoftwarepuwithout
  88.      specific, written prior permission.
  89.      Written by:   Robert  C. Pendleton  Evans &  Sutherland,
  90.      Interactive Systems Division, Salt Lake City, Utah.
  91.      Modified for ISETL by Gary Levin
  92.  
  93.  
  94. 2                                                         CONTENTS
  95.  
  96. Contents
  97. 1Running ISETL                                                   4
  98.  
  99. 2Characters, Keywords, and Identifiers                           6
  100.  2.1Character Set : :: :: :: :: :: :: ::: :: :: :: :: :: :: :: : 6
  101.  2.2Keywords: :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: : 6
  102.  2.3Identifiers: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: : 7
  103. 3Simple Data Types                                               7
  104.  3.1Integers: :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: : 7
  105.  3.2Floating_Point Numbers  :: :: :: ::: :: :: :: :: :: :: :: : 7
  106.  3.3Booleans: :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: : 8
  107.  
  108.  3.4Strings : :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: : 8
  109.  3.5Atoms: :: :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: : 9
  110.  3.6Files: :: :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: : 9
  111.  3.7Undefined :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :10
  112. 4Compound Data Types                                            10
  113.  4.1Sets : :: :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :10
  114.  4.2Tuples :: :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :11
  115.  4.3Maps : :: :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :12
  116.  
  117. 5Funcs                                                          12
  118. 6The ISETL Grammar --- Annotated                                16
  119.  6.1Terminology: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :16
  120.  6.2Input at the Prompt : :: :: :: :: ::: :: :: :: :: :: :: :: :17
  121.  6.3Program : :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :17
  122.  6.4Statements : :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :17
  123.  6.5Iterators :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :23
  124.  6.6Formers : :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :25
  125.  6.7Selectors :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :25
  126.  6.8Left Hand Sides :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :27
  127.  6.9Expressions: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :27
  128.  6.1Function Constants :: :: :: :: :: ::: :: :: :: :: :: :: :: :33
  129.  
  130. 7Pre-defined Functions                                          35
  131.  7.1Functions on Integers :: :: :: :: ::: :: :: :: :: :: :: :: :35
  132.  7.2Functions on Floating Point Numbers : :: :: :: :: :: :: :: :35
  133.  7.3Functions on Sets  :: :: :: :: :: ::: :: :: :: :: :: :: :: :35
  134.  7.4Functions on Maps  :: :: :: :: :: ::: :: :: :: :: :: :: :: :36
  135.  
  136.  
  137. CONTENTS                                                         3
  138.  
  139.  7.5Standard Mathematical Functions : ::: :: :: :: :: :: :: :: :36
  140.  7.6Type Testers :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :37
  141.  7.7Input/Output Functions : :: :: :: ::: :: :: :: :: :: :: :: :37
  142.  7.8Miscellaneous : :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :39
  143.  7.9Tuple: :: :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :39
  144. 8Precedence Rules                                               40
  145. 9Directives                                                     41
  146.  9.1Brief Descriptions :: :: :: :: :: ::: :: :: :: :: :: :: :: :41
  147.  9.2!clear and !edit : :: :: :: :: :: ::: :: :: :: :: :: :: :: :43
  148.  9.3!allocate and !memory :: :: :: :: ::: :: :: :: :: :: :: :: :44
  149.  9.4!watch and !unwatch : :: :: :: :: ::: :: :: :: :: :: :: :: :44
  150.  9.5!record : :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :45
  151.  9.6!system : :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :45
  152.  
  153. 1Editors                                                        46
  154.  10.MSDOS Screen Editor : :: :: :: :: ::: :: :: :: :: :: :: :: :46
  155.  10.Mac Screen Editor  :: :: :: :: :: ::: :: :: :: :: :: :: :: :47
  156.  10.Interactive Line Editor (ILE)  :: ::: :: :: :: :: :: :: :: :48
  157. 1Runtime Errors                                                 56
  158.  11.Fatal Errors :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :56
  159.  11.Operator Related Messages : :: :: ::: :: :: :: :: :: :: :: :57
  160.  11.General Errors  :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :58
  161.  
  162. 1The ISETL Grammar --- Compressed                               63
  163.  12.Input at the Prompt : :: :: :: :: ::: :: :: :: :: :: :: :: :63
  164.  12.Program : :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :63
  165.  12.Statements : :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :63
  166.  12.Iterators :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :64
  167.  12.Selectors :: :: :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :64
  168.  12.Left Hand Sides :: :: :: :: :: :: ::: :: :: :: :: :: :: :: :64
  169.  12.Expressions and Formers  :: :: :: ::: :: :: :: :: :: :: :: :65
  170.  12.Function Constants :: :: :: :: :: ::: :: :: :: :: :: :: :: :66
  171.  
  172.  
  173. 4                                                  1 RUNNING ISETL
  174.  
  175. 1 Running ISETL
  176. ISETL is  an interpreted, interactive  version of the  programming
  177. language SETL.   It is invoked by  typing a command line  with the
  178. executable name,  say isetl, along  with optional file names  that
  179. are discussed below.2
  180.  
  181.    There is  no compiler for  ISETL.   When ISETL  is running,  it
  182. prompts for input with  the character ``>''.  Input consists  of a
  183. sequence of  expressions (each terminated  by a semicolon  ``;''),
  184. statements, and  programs.   Each input is  acted upon as soon  as
  185. it is entered.   These actions are  explained below.  In  the case
  186. of expressions, the result  includes its value being printed.   If
  187. you have  not completed your  entry, you  will receive the  prompt
  188. ``>>'', indicating that more is expected.
  189.  
  190.   1. ISETL is exited by typing  ``!quit''.  It may also  be exited
  191.      by ending  the standard  input.   In  Unix, this  is done  by
  192.      typing ctrl-D.  In MS-DOS, ctrl-Z and ctrl-D will work.
  193.  
  194.   2. A  common  mistake  is   omitting  the  semicolon  after   an
  195.      expression.    ISETL  will wait  until  it gets  a  semicolon
  196.      before proceeding.  The doubled prompt  ``>>'' indicates that
  197.      ISETL is expecting more input.
  198.  
  199.   3. ISETL can get its input from sources other  than the standard
  200.      input.
  201.  
  202.      (a) If  there  is  an initialization  file3  in  the  current
  203.          directory, then  the first  thing ISETL will  do is  read
  204.          this file.
  205. -2The-Macintosh-version-is-clickable.
  206.  3Initialization files  are called either  .isetlrc or  isetl.ini.
  207. The file is looked for in:
  208.  i. the current directory
  209. ii. the directory containing isetl.exe (MSDOS and Mac)
  210. ii. the home directory (Unix, VMS) or root (MSDOS)
  211. iv. in the symbol ISETLINI: (VMS only)
  212. Only  one initialization  file  is  read.    The same  pattern  is
  213. searched for the ile initialization file.
  214.  
  215.  
  216.                                                                  5
  217.  
  218.      (b) Next,  if the  command line  has any  file names  listed,
  219.          ISETL will read each of these in turn.4
  220.          Thus, if the command line reads,
  221.                           isetl file.1 blue green
  222.  
  223.          ISETL will  first read  from ``.isetlrc''  if it  exists,
  224.          and  then  from  ``file.1'',  then  ``blue'',   and  then
  225.          ``green''.    Finally, it  is ready  for  input from  the
  226.          terminal.
  227.      (c) If there is a  file available --- say ``file.2''  --- and
  228.          ISETL  is given  (at any  time),  the following  line  of
  229.          input,
  230.  
  231.                               !include file.2
  232.  
  233.          then it will take its input from  ``file.2'' before being
  234.          ready for  any further  input.   The material  in such  a
  235.          file is treated exactly  as if it were typed  directly at
  236.          the keyboard, and it can be followed  on subsequent lines
  237.          by any  additional information that  the user would  like
  238.          to enter.
  239.          Consider  the   following  (rather  contrived)   example:
  240.          Suppose that the file ``file.3'' contained  the following
  241.          data:
  242.                            5, 6, 7, 3, -4, "the"
  243.  
  244.          Then if the user typed,
  245.  
  246.                          > seta := {
  247.                          >> !include file.3
  248.                          !include file.3 completed
  249.                          >> , x };
  250.  
  251.          the effect would be  exactly the same as if the  user had
  252.          entered,
  253. -4This-feature-is--system-dependent.   To provide this feature  in
  254. VMS, you must  define isetl :== $your$disk:[your.dir]isetl.exe  in
  255. your login.com.  The leading $ makes this a  foreign command.  The
  256. rest is the complete path to the executable version of ISETL.
  257.  
  258.  
  259. 6                          2 CHARACTERS, KEYWORDS, AND IDENTIFIERS
  260.                  > seta := {5, 6, 7, 3, -4, "the", x};
  261.  
  262.  
  263.          The line ``!include  file.3 completed'' comes from  ISETL
  264.          and is always printed after an ``!include''.
  265.   4. Comments
  266.  
  267.      If a  dollar sign ``$''  appears on a  line, then  everything
  268.      that appears until the end of the line is ignored by ISETL.
  269.   5. After a  program or  statement has  executed,  the values  of
  270.      global  variables  persist.    The  user  can  then  evaluate
  271.      expressions in terms of these variables.  (See  section 5 for
  272.      more detail on scope.)
  273.  
  274. 2 Characters, Keywords, and Identifiers
  275.  
  276. 2.1 Character Set
  277.  
  278. The following is a list of characters used by ISETL.
  279.         @ [ ] ; : = | { } ( ) . # ? * / + - _ " < > % ~ ,
  280.  
  281.                      a --- z A --- Z 0 --- 9
  282.  
  283. In addition, the following character-pairs are used.
  284.               :=    ..    **    /=    <=    >=    ->
  285.  
  286.    The characters ``:''  and ``|'' may be used interchangably.
  287.  
  288. 2.2 Keywords
  289. The following is a list of ISETL keywords.
  290.  
  291.  
  292.         and     false    iff    not      program   true
  293.         div     for      impl   notin    read      union
  294.         do      forall   in     of       readf     value
  295.         else    from     inter  om (OM)  return    where
  296.         elseif  fromb    less   opt      subset    while
  297.         end     frome    local  or       take      with
  298.         exists  func     mod    print    then      write
  299.                 if       newat  printf   to        writeln
  300.  
  301.  
  302. 2.3 Identifiers                                                  7
  303.  
  304. 2.3 Identifiers
  305.   1. An identifier is a sequence of alphanumeric  characters along
  306.      with the underscore,  ``_''.  It  must begin with a  letter.
  307.      Upper or  lower case  may be  used, and  ISETL preserves  the
  308.      distinction.  (I.e.:   a_good_thing and A_Good_ Thing are
  309.      both legal and are different.)
  310.  
  311.   2. An identifier serves  as a variable and  can take on a  value
  312.      of any ISETL data type.   The type of a variable  is entirely
  313.      determined by the  value that is  assigned to it and  changes
  314.      when a value of a different type is assigned.
  315.  
  316. 3 Simple Data Types
  317.  
  318. 3.1 Integers
  319.  
  320.   1. There is no limit to the size of integers.5
  321.  
  322.   2. An integer constant is a sequence of one or more digits.   It
  323.      represents an unsigned integer.
  324.   3. On  input  and  output,  long  integers  may   be  broken  to
  325.      accommodate limited  line length.   A  backslash (``\'')  at
  326.      the end of  a sequence of  digits indicates that the  integer
  327.      is continued on the next line.
  328.  
  329.         >       123456\
  330.         >>        789;
  331.         123456789;
  332.  
  333. 3.2 Floating_Point Numbers
  334.  
  335.   1. The possible  range  of floating_ point numbers  is  machine
  336.      dependent.    At a  minimum,  the values  will have  5  place
  337.      accuracy, with a range of approximately 1 0 3.
  338.   2. A floating_ point constant  is a  sequence  of one  or  more
  339.      digits, followed  by a  decimal point,  followed  by zero  or
  340. ---------------------------
  341.  5No practical  limit.   Actually limited  to about 20,000  digits
  342. per integer.
  343.  
  344.  
  345. 8                                              3 SIMPLE DATA TYPES
  346.  
  347.      more digits.    Thus,  2.0  and 2.    are  legal, but  .5  is
  348.      illegal.
  349.  
  350.      A floating_point  constant may be  followed by an  exponent.
  351.      An exponent consists of  one of the characters ``e'',  ``E'',
  352.      ``f'',  ``F''  followed  by a  signed  or  unsigned  integer.
  353.      The value  of  a floating_point  constant  is determined  as
  354.      in scientific  notation.   Hence, for  example, 0.2,  2.0e-1,
  355.      20.0e-2  are  all equivalent.     As  with  integers,  it  is
  356.      unsigned.
  357.  
  358.  
  359.   3. Different systems use different printed  representations when
  360.      floating point values  are out of the  machine's range.   For
  361.      example, when the  value is too  large, the Macintosh  prints
  362.      ``+++++'' and the Sun prints ``Infinity''.
  363.  
  364.  
  365.  
  366. 3.3 Booleans
  367.  
  368.   1. A Boolean  constant is  one of  the keywords  true or  false,
  369.      with the obvious meaning for its value.
  370.  
  371.  
  372.  
  373.  
  374. 3.4 Strings
  375.  
  376.   1. A string  constant  is any  sequence of  characters  preceded
  377.      and followed  by a double  quote, ``"''.    A string may  not
  378.      be split  across lines.    Large strings  may be  constructed
  379.      using the operation  of concatenation.   Strings may also  be
  380.      surrounded by single quotes, ``'''.
  381.  
  382.      The  backslash  convention  may  be  used  to  enter  special
  383.      characters.    When pretty-printing,  these  conventions  are
  384.      used for  output.    In  the  case of  formated  output,  the
  385.      special characters are printed.
  386.  
  387.  
  388. 3.5 Atoms                                                        9
  389.              \b      backspace
  390.              \f      formfeed (new page)
  391.              \n      newline (prints as CR-LF)
  392.              \q      double quote
  393.              \r      carriage return (CR)
  394.              \t      tab
  395.              \octal  character represented by octal
  396.                       Refer to an ASCII chart for meaning.
  397.              \other  other --- may be any character
  398.                       not listed above.
  399.  
  400.  
  401.      In particular, "\\" is a  single backslash.  You  may type,
  402.      "\"" for double quote, but the pretty printer  will print as
  403.      "\q".  ASCII values are limited to '\001' to '\377'.
  404.  
  405.      >       %+ [char(i): i in [1..127]];
  406.      "\001\002\003\004\005\006\007\b\t\n\013\f"
  407.      +"\r\016\017\020\021\022\023\024\025\026"
  408.      +"\027\030\031\032\033\034\035\036\037 !"
  409.      +"\q#$%&'()*+,-./0123456789:;<=>?@ABCDEF"
  410.      +"GHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijk"
  411.      +"lmnopqrstuvwxyz{|}~\177";
  412.  
  413. 3.5 Atoms
  414.  
  415.   1. Atoms are  ``abstract points''.    They  have no  identifying
  416.      properties other than their individual existence.
  417.  
  418.   2. The keyword newat has as its value an atom  never before seen
  419.      in this session of ISETL.
  420.  
  421. 3.6 Files
  422.  
  423.   1. A file  is an  ISETL value  that corresponds  to an  external
  424.      file in the operating system environment.
  425.  
  426.   2. They  are   created  as   a   result  of   applying  one   of
  427.      the  pre-defined  functions  openr,  opena,   openw.     (See
  428.      section 7.7.)
  429.  
  430.  
  431. 10                                           4 COMPOUND DATA TYPES
  432.  
  433. 3.7 Undefined
  434.   1. The data type undefined  has a single value  --- OM.  It  may
  435.      also be entered as om.
  436.  
  437.   2. Any identifier  that has not  been assigned  a value has  the
  438.      value OM.
  439.  
  440. 4 Compound Data Types
  441.  
  442. 4.1 Sets
  443.  
  444.   1. Only finite sets may be  represented in ISETL.   The elements
  445.      may be of  any type, mixed  heterogeneously.  Elements  occur
  446.      at most once per set.
  447.  
  448.   2. OM may  not be  an element  of a  set.   Any  set that  would
  449.      contain OM is considered to be undefined.
  450.  
  451.   3. The  order of  elements  is  not  significant in  a  set  and
  452.      printing  the  value of  a  set  twice  in  succession  could
  453.      display the elements in different orders.
  454.   4. Zero or more  expressions, separated  by commas and  enclosed
  455.      in braces (``{''  and ``}'') evaluates  to the set  whose
  456.      elements are the values of the enclosed expressions.
  457.  
  458.      Note that  as a  special case,  the empty set  is denoted  by
  459.      { }.
  460.  
  461.   5. There are syntactic  forms, explained in  the grammar, for  a
  462.      finite set  that is  an arithmetic  progression of  integers,
  463.      and also  for a  finite set  obtained  from a  set former  in
  464.      standard mathematical notation.
  465.      For example, the value of the following expression
  466.  
  467.                { x+y : x,y in {-1,-3..-100} | x /= y };
  468.  
  469.  
  470.      is  the  set of  all  sums  of  two  different  odd  negative
  471.      integers larger than ?1 0 0 .
  472.  
  473.  
  474. 4.2 Tuples                                                      11
  475.  
  476. 4.2 Tuples
  477.   1. A tuple is an infinite sequence of components,  of which only
  478.      a finite number  are defined.  The  components may be of  any
  479.      type, mixed heterogeneously.   The  values of components  may
  480.      be repeated.
  481.  
  482.   2. OM is a legal value for a component.
  483.  
  484.   3. The order of  the components of a tuple  is significant.   By
  485.      treating the tuple as a function over  the positive integers,
  486.      you  can   extract  individual   components  and   contiguous
  487.      subsequences (slices) of the tuple.
  488.  
  489.   4. Zero or more  expressions, separated  by commas and  enclosed
  490.      in square brackets (``[''  and ``]'') evaluates to the  tuple
  491.      whose  defined components  are  the values  of  the  enclosed
  492.      expressions.
  493.      Note that as  a special case, the  empty tuple is denoted  by
  494.      [ ].  This tuple is undefined everywhere.
  495.  
  496.   5. The  syntactic   forms  for  tuples   of  finite   arithmetic
  497.      progressions and tuple formers are similar to  those provided
  498.      for sets.  The  only difference is the use of  square, rather
  499.      than curly, brackets.
  500.  
  501.   6. The length of a tuple is the largest index  (counting from 1)
  502.      for which a  component is defined (that  is, is not equal  to
  503.      OM). It can change at run-time.
  504.  
  505.   7. Tuples usually are indexed  starting at 1, but they  can have
  506.      different starting  indices.   See page  33 and  page 39  for
  507.      definitions.
  508.  
  509.   8. Tuples created  by a  FORMER have the  default origin.    See
  510.      origin for how to redefine the default.
  511.  
  512.   9. Tuples that  result from operations  on other tuples  inherit
  513.      their origin.   Generally, the result inherits the  origin of
  514.      the leftmost tuple argument.
  515.  
  516.  
  517. 12                                                         5 FUNCS
  518.  
  519. 4.3 Maps
  520. Maps form a subclass of sets.
  521.  
  522.   1. A map is  a set that  is either empty  or whose elements  are
  523.      all ordered pairs.   An ordered pair  is a tuple whose  first
  524.      two components and no others are defined.
  525.  
  526.   2. There are  two special operators  for evaluating  a map at  a
  527.      point in its domain.  Suppose that F is a map.
  528.  
  529.      (a) F(EXPR)  will  evaluate  to  the  value   of  the  second
  530.          component  of  the ordered  pair  whose  first  component
  531.          is  the value  of  EXPR, provided  there is  exactly  one
  532.          such ordered  pair in  F; if there  is no  such pair,  it
  533.          evaluates to OM; if  there are many such pairs,  an error
  534.          is reported.
  535.      (b) F{EXPR} will  evaluate to  the set of  all values  of
  536.          second  components of  ordered  pairs  in F  whose  first
  537.          component is  the value  of EXPR.   If  there is no  such
  538.          pair, its value is the empty set.
  539.  
  540.   3. A map in which no  value appears more than once as  the first
  541.      component of an  ordered pair is  called a single-valued  map
  542.      or smap; otherwise, the  map is called a multi-valued  map or
  543.      mmap.
  544.  
  545. 5 Funcs
  546.  
  547.   1. A func  is an  ISETL value  that may  be applied  to zero  or
  548.      more values passed  to it as  arguments.   It then returns  a
  549.      value specified by  the definition of the  func.  Because  it
  550.      is a value, an ISETL  func can be assigned to  an identifier,
  551.      passed as  an argument,  etc.   Evaluation of  an ISETL  func
  552.      can have  side-effects determined  by the  statements in  the
  553.      definition of the func.  Thus, it also serves  the purpose of
  554.      what is often called a procedure.
  555.  
  556.   2. The return statement is only  meaningful inside a func.   Its
  557.      effect is  to terminate execution  of the  func and return  a
  558.  
  559.  
  560.                                                                 13
  561.  
  562.      value to the caller.  The form ``return   expr;'' returns the
  563.      value of expr; ``return;'' returns OM.
  564.      ISETL inserts return; just before the end of every func.
  565.  
  566.   3. A func is the computational representation of a  function, as
  567.      a map is the ordered pair representation, and a  tuple is the
  568.      sequence representation.    Just as  tuples and  maps may  be
  569.      modified at a  point by assignment, so  can funcs.   However,
  570.      if the value  at a  point is structured,  you may not  modify
  571.      that at a point as well.
  572.         >       x := func(i);
  573.         >>               return char(i);
  574.         >>           end;
  575.         >       x(97);
  576.         "a";
  577.         >       x(97) := "q";
  578.         >       x(97);
  579.         "q";
  580.         >       x(97)(1) := "abc";
  581.         ! Error: Only one level of selection allowed
  582.  
  583.      x may be  modified at a  point.  The  assignment to x(97)  is
  584.      legal.   However, the following  assignment is not  supported
  585.      at this time, because you are trying to  modify the structure
  586.      of the value returned.
  587.   4. A number  of  functions have  been  pre-defined as  funcs  in
  588.      ISETL.   A list of their definitions  is given in section  7.
  589.      These are not keywords and may be changed by the user.   They
  590.      may not be modified at a point, however.
  591.  
  592.   5. It is  possible  for the  user to  define  her/his own  func.
  593.      This is done with the following syntax:
  594.         func(list-of-parameters);
  595.             local list-of-local-ids;
  596.             value list-of-global-ids;
  597.             statements;
  598.         end
  599.  
  600.      Alternately, one may write
  601.  
  602.  
  603. 14                                                         5 FUNCS
  604.  
  605.         : list-of-parameters -> result :
  606.      if the function simply consists of evaluating an expression.
  607.  
  608.      (a) The  declaration  of  local ids  may  be  omitted  if  no
  609.          local variables  are needed.   The  declaration of  value
  610.          ids  represents  global variables  whose  current  values
  611.          are to  be remembered and  used at  the time of  function
  612.          invocation;  these may  be omitted if  not needed.    The
  613.          list-of-parameters  may  be   empty,  but  the   pair  of
  614.          parentheses must be present.
  615.  
  616.      (b) Parameters and  local-ids are  local to  the func.    See
  617.          below for a discussion of scope.
  618.      (c) The syntax described  above is for an expression  of type
  619.          func.    As with  any expression,  it  may be  evaluated,
  620.          but the  value has no  name.   Thus, the definition  will
  621.          typically be  part of an  assignment statement or  passed
  622.          as a parameter.  As a very simple example, consider:
  623.             cube_plus := func(x,y);
  624.                              return x**3 + y;
  625.                          end;
  626.  
  627.          After having executed this input, ISETL  will evaluate an
  628.          expression such as cube_plus(2,5) as 1 3 .
  629.      (d) Parameters are passed by  value.  It is an error  to pass
  630.          too many or  too few arguments.   It is possible to  make
  631.          some parameters optional.
  632.  
  633.                    f := func(a,b,c opt x,y,z); ... end;
  634.          f can be called with  3, 4, 5, or 6 arguments.   If there
  635.          are fewer  than 6  arguments, the  missing arguments  are
  636.          considered to be OM.
  637.  
  638.      (e) Scope is lexical (static) with retention.   Lexical means
  639.          that references  to  global variables  are determined  by
  640.          where  the func  was created,  not by  where  it will  be
  641.          evaluated.  Retention  means that even if the  scope that
  642.          created the func  has been exited, its  variables persist
  643.          and can be used by the func.
  644.  
  645.  
  646.                                                                 15
  647.  
  648.          By  default,  references  to global  variables  will  use
  649.          the value  of the variable  at the  time the function  is
  650.          invoked.  The  value declaration causes the value  of the
  651.          global variable  at the time  the func  is created to  be
  652.          used.
  653.      (f) Here  is  a  more  complicated  example  of  the  use  of
  654.          func.  As  defined below, compose takes two  functions as
  655.          arguments and creates their functional composition.   The
  656.          functions can be any ISETL values that may  be applied to
  657.          a single argument; e.g.  func, tuple, smap.
  658.             compose := func(f,g);
  659.                            return :x -> f(g(x)) :
  660.                        end;
  661.             twice :=   :a -> 2*a: ;
  662.             times4 :=  compose(twice,twice);
  663.          Then the value  of times4(3) would be  12.  The value  of
  664.          times4 needs to refer to the values of f  and g, and they
  665.          remain  accessible to  times4,  even though  compose  has
  666.          returned.
  667.  
  668.      (g) Finally, here  is an example  of functions modified at  a
  669.          point and functions  that capture the current value  of a
  670.          global.
  671.             f := func(x);
  672.                      return x + 4;
  673.                  end func;
  674.             gs := [ func(x); value N; return x+3*N; end
  675.                     : N in [1..3] ];
  676.             f(3) := 21;
  677.          After this is  executed, f(1) is 5,  f(2) is 6, but  f(3)
  678.          is 21.  gs(2)(4) is 10 (4+3*2).
  679.  
  680.  
  681. 16                               6 THE ISETL GRAMMAR --- ANNOTATED
  682.  
  683. 6 The ISETL Grammar --- Annotated
  684. 6.1 Terminology
  685.  
  686.   1. In  what  follows,  the  symbol  ID  refers  to  identifiers,
  687.      and INTEGER,  FLOATING_POINT, BOOLEAN,  and STRING refer  to
  688.      constants of  type  integer,  floating_point,  Boolean,  and
  689.      string, which have  been explained above.   Any other  symbol
  690.      in capital letters is explained in the grammar.
  691.  
  692.   2. Definitions appear as:
  693.  
  694.  
  695.         STMT   -->  LHS := EXPR ;
  696.  
  697.         STMT   -->  if EXPR then STMTS ELSE-IFS ELSE-PART end
  698.      indicating that  STMT can be  either an assignment  statement
  699.      or a  conditional statement.   The  definitions for  ELSE-IFS
  700.      and ELSE-PART are in the section for statements,  and EXPR in
  701.      the section for expressions.
  702.  
  703.   3. Rules are sometimes  given informally in  English.  The  rule
  704.      is then quoted.
  705.  
  706.   4. Spaces  are   not  allowed  within   any  of  the   character
  707.      pairs  listed  in  section  2,  nor  within  an  ID,  INTEGER
  708.      constant,  FLOATING_POINT  constant,  or keyword.     Spaces
  709.      are required  between keywords, IDs,  INTEGER constants,  and
  710.      FLOATING_POINT constants.
  711.  
  712.   5. ISETL treats  ends of line  and tabs  as spaces.   Any  input
  713.      can be spread across lines without changing the  meaning, and
  714.      ISETL will not consider  it to be complete until  a semicolon
  715.      (``;'') is  entered.   The  only exceptions to  this are  the
  716.      ! directives,  which are  ended with a  carriage return,  and
  717.      the fact that  a quoted string cannot  be typed on more  than
  718.      one line.
  719.  
  720.    The annotated grammar  below is divided into sections  relating
  721. to the major parts of the language.
  722.  
  723.  
  724. 6.2 Input at the Prompt                                         17
  725.  
  726. 6.2 Input at the Prompt
  727.    INPUT   -->   PROGRAM
  728.  
  729.    INPUT   -->   STMT
  730.    INPUT   -->   EXPR ;
  731.       The EXPR is evaluated and the value is printed.
  732.  
  733.  
  734. 6.3 Program
  735. Programs are usually read  from a file, only because they  tend to
  736. be long.
  737.  
  738.  
  739.    PROGRAM   -->   program ID ; LOCALS VALUES STMTS end ;
  740.       Of  course,  it can  appear  on  several  lines.    One  may
  741.       optionally close with  end program.   LOCALS and VALUES  are
  742.       defined in section 6.10.
  743.  
  744. 6.4 Statements
  745.  
  746.    STMT   -->   LHS := EXPR ;
  747.       First, the left  hand side (LHS)  is evaluated to  determine
  748.       the target(s) for the  assignment, then the right hand  side
  749.       is evaluated.   Finally, the assignment is  made.  If  there
  750.       are  some targets  for  which  there  are no  values  to  be
  751.       assigned, they receive the value OM.  If there are values to
  752.       be assigned, but no  corresponding targets, then the  values
  753.       are ignored.
  754.       Examples:
  755.          a := 4;
  756.  
  757.              a is changed to contain the value 4 .
  758.          [a,b] := [1,2];
  759.  
  760.              a is assigned 1 and b is assigned 2 .
  761.  
  762.          [x,y] := [y,x];
  763.  
  764.              Swap x and y.
  765.  
  766.  
  767. 18                               6 THE ISETL GRAMMAR --- ANNOTATED
  768.  
  769.          f(3) := 7;
  770.              If f is a tuple, then the effect of this statement is
  771.              to assign 7  as  the value of  the third component  of
  772.              f.  If f is a map, then its effect is  to replace all
  773.              pairs beginning with 3  by the  pair [3,7] in the  set
  774.              of ordered pairs f.   If f is a func, then  f(3) will
  775.              be 7 , and all other values of f will be as they  were
  776.              before the assignment.
  777.  
  778.    STMT   -->   EXPR ;
  779.       The expression is evaluated and the value ignored.   This is
  780.       usually used to invoke procedures.
  781.  
  782.    STMT   -->   if EXPR then STMTS ELSE-IFS ELSE-PART end ;
  783.       The EXPRs after if  and elseif are evaluated in  order until
  784.       one is found to be true.  The STMTS following the associated
  785.       then are executed.    If no EXPR  is found to  be true,  the
  786.       STMTS in the  ELSE-PART are  executed.   In this last  case,
  787.       if the ELSE-PART is  omitted, this statement has no  effect.
  788.       One may optionally close with end  if.  See the end  of this
  789.       section for the definitions of ELSE-IFS and ELSE-PART.
  790.    STMT   -->   for ITERATOR do STMTS end ;
  791.       The STMTS are  executed for each  instance generated by  the
  792.       iterator.  One may optionally close with end for.
  793.    STMT   -->   while EXPR do STMTS end ;
  794.       EXPR must evaluate  to a Boolean value.   EXPR is  evaluated
  795.       and the  STMTS are  executed repetitively  as  long as  this
  796.       value is  equal to  true.    One may  optionally close  with
  797.       end while.
  798.  
  799.    STMT   -->   read LHS-LIST ;
  800.       ISETL gives a question mark (``?'')  prompt  and waits until
  801.       an expression  has been  entered.   This  EXPR is  evaluated
  802.       and the result  is assigned to  the first item in  LHS-LIST.
  803.       This is  repeated for  each item  in  LHS-LIST.   As  usual,
  804.       terminate the expressions  with a  semicolon.   Note:  If  a
  805.       read statement appears in an !include file, then  ISETL will
  806.       look at the next input in that file for the expression(s) to
  807.       be read.
  808.  
  809.  
  810. 6.4 Statements                                                  19
  811.  
  812.    STMT   -->   read LHS-LIST from EXPR ;
  813.       This is  the same as  read LHS-LIST;  except that EXPR  must
  814.       have a value of type file.   The values to be read  are then
  815.       taken from the external file specified by the value of EXPR.
  816.       If there are more values in the file than items in LHS-LIST,
  817.       then the extra values are left  to be read later.   If there
  818.       are more items in LHS-LIST than values in the file, then the
  819.       extra items are assigned the value OM.  In  the latter case,
  820.       the function  eof will return  true when  given the file  as
  821.       parameter.  Before this statement is executed,  the external
  822.       file in question  must have been  opened for reading by  the
  823.       pre-defined function openr (see section 7.7).
  824.    STMT   -->   readf PAIR-LIST ;
  825.  
  826.    STMT   -->   readf PAIR-LIST from EXPR ;
  827.       The relation  between these  two forms  is the  same as  the
  828.       relation between the two forms of read, with  the second one
  829.       coming from a  file.  The  elements in the PAIR-LIST  define
  830.       the formating  used.    See  PAIR-LIST at  the end  of  this
  831.       section.
  832.    STMT   -->   print EXPR-LIST ;
  833.       Each expression  in EXPR-LIST  is evaluated  and printed  on
  834.       standard output.   The  output values  are formated to  show
  835.       their structure,  with line breaks  at reasonable  positions
  836.       and meaningful indentation.
  837.  
  838.    STMT   -->   print EXPR-LIST to EXPR ;
  839.       As in  read..from..., EXPR  must be  a value  of type  file.
  840.       The values  are written to  the external  file specified  by
  841.       the value of  EXPR.   Before executing  this statement,  the
  842.       external file in question must have been opened  for writing
  843.       by one  of the  pre-defined functions  openw  or opena  (see
  844.       section 7.7).
  845.    STMT   -->   printf PAIR-LIST ;
  846.  
  847.    STMT   -->   printf PAIR-LIST to EXPR ;
  848.       The relation  between these  two forms  is the  same as  the
  849.       relation between the two forms of print, with the second one
  850.       going to a file.   The elements in the PAIR-LIST  define the
  851.  
  852.  
  853. 20                               6 THE ISETL GRAMMAR --- ANNOTATED
  854.  
  855.       formating used.  See  PAIR-LIST at the end of  this section.
  856.       See write and writeln below.
  857.    STMT   -->   return ;
  858.       return is only meaningful inside  a func.  Its effect  is to
  859.       terminate execution of the func and return OM to the caller.
  860.       ISETL inserts return; just before the end of every func.  If
  861.       return appears at the ``top  level'', e.g.  as input  at the
  862.       keyboard, a run time error will occur.
  863.    STMT   -->   return EXPR ;
  864.       Same as return; except that EXPR is evaluated  and its value
  865.       is returned as the value of the func.
  866.  
  867.    STMT   -->   take LHS from LHS ;
  868.       The second LHS must evaluate to a set.  An arbitrary element
  869.       of the set is assigned to the first LHS and removed from the
  870.       set.
  871.    STMT   -->   take LHS frome LHS ;
  872.       The second LHS must evaluate to a tuple (or a string).   The
  873.       value of its last  defined component (or last character)  is
  874.       assigned to the  first LHS and replaced  by OM in the  tuple
  875.       (deleted from the string).
  876.  
  877.    STMT   -->   take LHS fromb LHS ;
  878.       The second  LHS  must evaluate  to a  tuple  (or a  string).
  879.       The value  of its first  component (defined  or not)  (first
  880.       character) is assigned to  the first LHS and all  components
  881.       of the tuple (characters of the string) are shifted left one
  882.       place.  That  is, the new value of  the ithcomponent  is the
  883.       old value of the (i+1 )stcomponent (i = 1 ;2 ;.).
  884.    STMT   -->   write PAIR-LIST ;
  885.  
  886.    STMT   -->   write PAIR-LIST to EXPR ;
  887.    STMT   -->   writeln PAIR-LIST ;
  888.  
  889.    STMT   -->   writeln PAIR-LIST to EXPR ;
  890.       write is equivalent to printf, provided for  the convenience
  891.       of the Pascal  user.  writeln  is equivalent to write,  with
  892.       '\n' as the last item of  the list.  This is  also provided
  893.       for user convenience.
  894.  
  895.  
  896. 6.4 Statements                                                  21
  897.  
  898.        >       readf x;
  899.           1.34
  900.        >       x;
  901.        1.34000e+00;
  902.  
  903.        >       readf y;
  904.        123,456
  905.        >       y;
  906.        "123,456";
  907.  
  908.                      Figure 1:  readf example
  909.  
  910.        >       printf 1/3: 15.10,  1/3:15.1,  1/3:15.01, "\n";
  911.        0.3333333135   0.3333333135            0.3
  912.  
  913.        printf 1/3: -17.10, 1/3:-17.1, 1/3:-17.01, "\n";
  914.        3.3333331347e-01 3.3333331347e-01          3.3e-01
  915.  
  916.                     Figure 2:  printf example
  917.  
  918.  
  919.    STMTS   -->    ``One or  more  instances  of  STMT.  The  final
  920. semicolon is optional.''
  921.  
  922.    ELSE-IFS   -->   ``Zero or more instances of ELSE-IF.''
  923.  
  924.    ELSE-IF   -->   elseif EXPR then STMTS
  925.  
  926.    ELSE-PART   -->   else STMTS
  927.       ``May be omitted.''
  928.  
  929.    PAIR-LIST   -->   ``One or more instances of PAIR, separated by
  930. commas.''
  931.  
  932.    PAIR   -->   EXPR : EXPR
  933.  
  934.    PAIR   -->   EXPR
  935.       When a PAIR  appears in a  readf, the first  EXPR must be  a
  936.       LHS. The meaning of the PAIR and the default  value when the
  937.  
  938.  
  939. 22                               6 THE ISETL GRAMMAR --- ANNOTATED
  940.  
  941.        >       printf 3*[""]+[1..30] : 7*[3] with "\n";
  942.                   1  2  3  4
  943.          5  6  7  8  9 10 11
  944.         12 13 14 15 16 17 18
  945.         19 20 21 22 23 24 25
  946.         26 27 28 29 30
  947.        >       x := [ [i,j,i+j] : i,j in [1..3] ];
  948.        >       printf x: 5*[ [0,"+",0, "=", 0], "\t" ]
  949.        >>                  with "\n", "\n";
  950.        1+1=2   1+2=3   1+3=4   2+1=3   2+2=4
  951.        2+3=5   3+1=4   3+2=5   3+3=6
  952.  
  953.              Figure 3:  printf with structure example
  954.  
  955.  
  956.       second EXPR is  omitted depends on  whether the PAIR  occurs
  957.       in readf or printf.  The second EXPR (or  its default value)
  958.       defines the format.
  959.         ? Input:  Input formats are integers.
  960.  
  961.           The integer  gives the maximum  number of characters  to
  962.           be read.    If  the first  sequence  of non-white  space
  963.           characters can be interpreted  as a number, that  is the
  964.           value read.  Otherwise, the first  non-white sequence is
  965.           returned as a string.
  966.           If  the  integer   is  negative  (say  ?i),   exactly  i
  967.           characters  will  be read  and  returned  as  a  string.
  968.           Therefore c:-1 will read one character into c.
  969.           If no  integer  is given,  there is  no  maximum to  the
  970.           number of characters that will be read.
  971.           See figure 1.
  972.  
  973.         ? Output:  Output formats are:  integers,  floating_point
  974.           numbers, strings, or tuples of output formats.
  975.           Integers  (and  the  integer  part  of   floating_point
  976.           numbers) represent the  minimal number of columns to  be
  977.           used.  The  fractional part of a floating_ point number
  978.           is used  to specify precision,  in terms of  hundredths.
  979.           The  precision controls  the number  of  places used  in
  980.  
  981.  
  982. 6.5 Iterators                                                   23
  983.  
  984.           floating_point numbers, and where breaks  occur in very
  985.           long integers.
  986.           Negative  values cause  floating_point  numbers  to  be
  987.           printed in scientific notation.
  988.           Notice that  there is a  limit to  the number of  useful
  989.           digits.   Also notice  that 15.1 is  the same as  15.10;
  990.           hence, both would use 15 columns and  10 decimal places.
  991.           See figure 2.
  992.           Strings  should  not  be  used  as  formats  outside  of
  993.           tuples.
  994.           Compound  objects (tuples  and  sets) iterate  over  the
  995.           format.   If the format is a  number, it is used  as the
  996.           format for each element.  If the format is  a tuple, the
  997.           elements of  the tuple  are cycled  among, with  strings
  998.           printed literally and other items used as formats.   See
  999.           figure 3.
  1000.           Default values are:
  1001.  
  1002.           -------------------------------------------------------
  1003.             Float               20  5
  1004.             Integer             10  50 (for breaking large ints)
  1005.             String               0
  1006.             Anything else       10
  1007.  
  1008. 6.5 Iterators
  1009.  
  1010. These  constructs are  used  to iterate  through a  collection  of
  1011. values,  assigning these  values  one at  a  time to  a  variable.
  1012. Iterators are  used in  the for  statement,  quantifiers, and  set
  1013. formers.
  1014.    A SIMPLE-ITERATOR generates a number of instances  for which an
  1015. assignment is made.  These assignments are  local to the iterator,
  1016. and  when it  is exited,  all  previous values  of  IDs that  were
  1017. used as  local variables  are restored.   That is,  these IDs  are
  1018. ``bound  variables'' whose  scope is  the construction  containing
  1019. the iterator.   (e.g., for statements, quantifiers,  formers, etc.
  1020. )
  1021.  
  1022.    ITERATOR   -->   ITER-LIST
  1023.  
  1024.  
  1025. 24                               6 THE ISETL GRAMMAR --- ANNOTATED
  1026.  
  1027.    ITERATOR   -->   ITER-LIST | EXPR
  1028.       EXPR must  evaluate  to a  Boolean.    Generates only  those
  1029.       instances generated by ITER-LIST for which the value of EXPR
  1030.       is true.
  1031.  
  1032.    ITER-LIST   -->   ``One or  more SIMPLE-ITERATORs separated  by
  1033. commas.''
  1034.       Generates all  possible instances for  every combination  of
  1035.       the SIMPLE-ITERATORs.   The  first SIMPLE-ITERATOR  advances
  1036.       most slowly.  Subsequent iterators may depend  on previously
  1037.       bound values.
  1038.  
  1039.    SIMPLE-ITERATOR   -->   BOUND-LIST in EXPR
  1040.       EXPR must  evaluate  to  a  set,  tuple,  or string.     The
  1041.       instances generated  are  all  possibilities in  which  each
  1042.       BOUND in BOUND-LIST is assigned a value that occurs in EXPR.
  1043.    SIMPLE-ITERATOR   -->   BOUND = ID ( BOUND-LIST )
  1044.       Here ID must have  the value of  an smap, tuple, or  string,
  1045.       and BOUND-LIST must have  the correct number of  occurrences
  1046.       of  BOUND corresponding  to  the  parameters  of ID.     The
  1047.       resulting instances are those  for which all occurrences  of
  1048.       BOUND in BOUND-LIST have all possible legal values and BOUND
  1049.       is assigned the corresponding value.
  1050.  
  1051.    SIMPLE-ITERATOR   -->   BOUND = ID { BOUND-LIST }
  1052.       Same as  the previous one  for the  case in which  ID is  an
  1053.       mmap.
  1054.  
  1055.    BOUND-LIST   -->   ``one or more BOUND, separated by commas''
  1056.  
  1057.    BOUND   -->   ~
  1058.       Corresponding value is thrown away.
  1059.    BOUND   -->   ID
  1060.       Corresponding value is assigned to ID.
  1061.  
  1062.    BOUND   -->   [ BOUND-LIST ]
  1063.       Corresponding  value  must  be  a  tuple,  and  elements  of
  1064.       the tuple  are  assigned to  corresponding elements  in  the
  1065.       BOUND-LIST.
  1066.  
  1067.  
  1068. 6.6 Formers                                                     25
  1069.  
  1070. 6.6 Formers
  1071. Generates the elements of a set or tuple.
  1072.  
  1073.    FORMER   -->   ``Empty''
  1074.       Generates the empty set or tuple.
  1075.  
  1076.    FORMER   -->   EXPR-LIST
  1077.       Values are explicitly listed.
  1078.    FORMER   -->   EXPR .. EXPR
  1079.       Both  occurrences  of   EXPR  must  evaluate  to   integers.
  1080.       Generates all  integers beginning  with the  first EXPR  and
  1081.       increasing by  1  for as  long  as the  second EXPR  is  not
  1082.       exceeded.  If the  first EXPR is larger than the  second, no
  1083.       values are generated.
  1084.    FORMER   -->   EXPR , EXPR .. EXPR
  1085.       All three  occurrences  of EXPR  must evaluate  to  integer.
  1086.       Generates all  integers beginning  with the  first EXPR  and
  1087.       incrementing by the value of the second EXPR minus the first
  1088.       EXPR.   If this difference is  positive, it generates  those
  1089.       integers that are not greater  than the third EXPR.   If the
  1090.       difference is negative, it generates those integers that are
  1091.       not less than the third EXPR.  If the difference is zero, no
  1092.       integers are generated.
  1093.  
  1094.    FORMER   -->   EXPR : ITERATOR
  1095.       The  value of  EXPR  for  each  instance  generated  by  the
  1096.       ITERATOR.
  1097.  
  1098. 6.7 Selectors
  1099.  
  1100. Selectors fall  into three  categories:  function  application,
  1101. mmap images, and slices.   A tuple, string, map, or func  (pre- or
  1102. user-defined) may be followed by a SELECTOR,  which has the effect
  1103. of specifying  a value  or group  of values  in the  range of  the
  1104. tuple, string, map,  or func.  Not all of the  following SELECTORs
  1105. can be used in all four cases.
  1106.  
  1107.    SELECTOR   -->   ( EXPR-LIST )
  1108.       Must be used with an smap, tuple, string, or func.
  1109.  
  1110.  
  1111. 26                               6 THE ISETL GRAMMAR --- ANNOTATED
  1112.  
  1113.       If used with a tuple or string, then EXPR-LIST can only have
  1114.       one element, which must evaluate to a positive integer.
  1115.       If used with a  func, arguments are passed to  corresponding
  1116.       parameters.   There must  be as  many arguments as  required
  1117.       parameters and no more than the optional parameters permit.
  1118.       If  used with  an  smap  and  EXPR-LIST has  more  than  one
  1119.       element, it is  equivalent to what it  would be if the  list
  1120.       were enclosed  in square brackets,  [ ].    Thus a  function
  1121.       of several  variables is interpreted  as a  function of  one
  1122.       variable --- the tuple  whose components are the  individual
  1123.       variables.
  1124.    SELECTOR   -->   { EXPR-LIST }
  1125.       Must be used  with an mmap,  tuple, or string.   Tuples  and
  1126.       strings will either select a singleton set or the empty set.
  1127.       The case  in which  the list has  more than  one element  is
  1128.       handled as above.
  1129.  
  1130.    SELECTOR   -->   ( EXPR .. EXPR )
  1131.       Must be used with a  tuple or string, and both  instances of
  1132.       EXPR must evaluate to a positive integer.
  1133.       The value is  the slice of the  original tuple or string  in
  1134.       the range specified by the  two occurrences of EXPR.   There
  1135.       are some  special rules  in this case.    To describe  them,
  1136.       suppose that the first EXPR  has the value a and  the second
  1137.       has the value b so that the selector is (a..b).
  1138.        a<=b      Value is the tuple or string with components
  1139.                  defined only at the integers from 1  to b? a+ 1 ,
  1140.                  inclusive.  The value of the ithcomponent is
  1141.                  the value of the (a+ i? 1 )stcomponent of the
  1142.                  value of EXPR.
  1143.        a = b+ 1  Value is the empty tuple.
  1144.        a > b+ 1  Run-time error.
  1145.    SELECTOR   -->   ( .. EXPR )
  1146.       Means the same as (low .. EXPR), where low is  1 for strings
  1147.       and lo(T) for tuple T.
  1148.  
  1149.    SELECTOR   -->   ( EXPR .. )
  1150.       Means the same  as ( EXPR  .. high ),  where high is #s  for
  1151.       string s and hi(T) for tuple T.
  1152.  
  1153.  
  1154. 6.8 Left Hand Sides                                             27
  1155.  
  1156.    SELECTOR   -->   ( )
  1157.       Used with a func that has no parameters.  It also works with
  1158.       an smap with [ ] in its domain.
  1159.  
  1160. 6.8 Left Hand Sides
  1161. The target for anything that has the effect of an assignment.
  1162.  
  1163.    LHS   -->   ID
  1164.  
  1165.    LHS   -->   LHS SELECTOR
  1166.       LHS must  evaluate to  a  tuple, string,  or map.    LHS  is
  1167.       modified by replacing the components designated by selector.
  1168.    LHS   -->   [ LHS-LIST ]
  1169.  
  1170.    LHS-LIST   -->   ``One or more  instances of LHS, separated  by
  1171. commas''
  1172.       Thus the input,
  1173.                         [A, B, C] := [1, 2, 3];
  1174.       has the effect of replacing A by 1 ,B by 2 , and C by 3 .
  1175.       Any LHS in the list can be replaced by ~.
  1176.  
  1177.       The effect is to omit any assignment to a LHS  that has been
  1178.       so replaced.  Thus the input,
  1179.                         [A, ~, C] := [1, 2, 3];
  1180.       replaces A by 1 ,C by 3 .
  1181.  
  1182. 6.9 Expressions
  1183. The first  few in  the following  list are values  of simple  data
  1184. types and they have been discussed before.
  1185.  
  1186.    EXPR   -->   ID
  1187.  
  1188.    EXPR   -->   INTEGER
  1189.    EXPR   -->   FLOATING-POINT
  1190.  
  1191.    EXPR   -->   STRING
  1192.    EXPR   -->   true
  1193.  
  1194.    EXPR   -->   false
  1195.  
  1196.  
  1197. 28                               6 THE ISETL GRAMMAR --- ANNOTATED
  1198.  
  1199.    EXPR   -->   OM
  1200.    EXPR   -->   newat
  1201.       The value is a new atom, different from any  other atom that
  1202.       has appeared before.
  1203.    EXPR   -->   FUNC-CONST
  1204.       A user-defined func.  See section 6.10.
  1205.    EXPR   -->   if EXPR then EXPR ELSE-IFS ELSE-PART end ;
  1206.       See definition  of  if under  STMT, page18.    ELSE-PART  is
  1207.       required, and each  part contains an expression rather  than
  1208.       statements.
  1209.  
  1210.    EXPR   -->   ( EXPR )
  1211.       Any expression can be enclosed in parentheses.  The value is
  1212.       the value of EXPR.
  1213.    EXPR   -->   [ FORMER ]
  1214.       Evaluates to the tuple  of those values generated by  FORMER
  1215.       in the order that former generates them.
  1216.    EXPR   -->   { FORMER }
  1217.       Evaluates to the set of those values generated by FORMER.
  1218.  
  1219.    EXPR   -->   # EXPR
  1220.       EXPR must be  a set,  tuple, or string.    The value is  the
  1221.       cardinality of  the set,  the length  of the  tuple, or  the
  1222.       length of the string.
  1223.    EXPR   -->   not EXPR
  1224.       Logical negation.  EXPR must evaluate to Boolean.
  1225.    EXPR   -->   + EXPR
  1226.       Identity function.  EXPR must evaluate to a number.
  1227.    EXPR   -->   - EXPR
  1228.       Negative of EXPR.  EXPR must evaluate to a number.
  1229.  
  1230.    EXPR   -->   EXPR SELECTOR
  1231.       EXPR must evaluate to an ISETL value that is, in the general
  1232.       sense, a  function.    That is,  it must  be a  map,  tuple,
  1233.       string, or func.  See section 6.7.
  1234.    EXPR   -->   EXPR . ID EXPR
  1235.       This is  equivalent  to ID(EXPR,EXPR).  It  lets you  use  a
  1236.       binary function as an infix  operator.  The space  after the
  1237.       ``.''  is optional.
  1238.  
  1239.  
  1240. 6.9 Expressions                                                 29
  1241.  
  1242.    EXPR   -->   EXPR . (EXPR) EXPR
  1243.       This is equivalent to  (EXPR)(EXPR,EXPR). It lets you use  a
  1244.       binary function as an infix  operator.  The space  after the
  1245.       ``.''  is optional.
  1246. In general, arithmetic operators and comparisons  may mix integers
  1247. and floating_ point.   The result of  an arithmetic operation  is
  1248. an  integer if  both  operands are  integers  and  floating_point
  1249. otherwise.  For simplicity, we will use the term  number to mean a
  1250. value that is either integer or floating_point.
  1251. Possible operators are:
  1252.  
  1253.                         + - * / div mod **
  1254.                             with less
  1255.                           = /= < > <= >=
  1256.                    union inter in notin subset
  1257.                          and or impl iff
  1258. See section 8 for precedence rules.
  1259. Any cases  not covered  in the  explanation for  an operator  will
  1260. result  in  an  error.     For  an  explanation  of  errors,   see
  1261. section 11.
  1262.  
  1263.    EXPR   -->   EXPR + EXPR
  1264.       If both  instances  of EXPR  evaluate  to numbers,  this  is
  1265.       addition.  If both instances of EXPR evaluate  to sets, then
  1266.       this is union.  If both instances of EXPR evaluate to tuples
  1267.       or strings, then this is concatenation.
  1268.    EXPR   -->   EXPR union EXPR
  1269.       An alternate form of +.  It is intended that it be used with
  1270.       sets, but it is in all ways equivalent to +.
  1271.  
  1272.    EXPR   -->   EXPR - EXPR
  1273.       If both  instances  of EXPR  evaluate  to numbers,  this  is
  1274.       subtraction.   If both instances  of EXPR evaluate to  sets,
  1275.       then this is set difference.
  1276.    EXPR   -->   EXPR * EXPR
  1277.       If both  instances  of EXPR  evaluate  to numbers,  this  is
  1278.       multiplication.     If  both  evaluate  to  sets,   this  is
  1279.       intersection.  If one instance of EXPR  evaluates to integer
  1280.       and the other to  a tuple or string,  then the value is  the
  1281.  
  1282.  
  1283. 30                               6 THE ISETL GRAMMAR --- ANNOTATED
  1284.  
  1285.       tuple or string, concatenated with itself the integer number
  1286.       of times, if the integer is positive; and the empty tuple or
  1287.       string, if the integer is less than or equal to zero.
  1288.    EXPR   -->   EXPR inter EXPR
  1289.       An alternate form of *.  It is intended that it be used with
  1290.       sets, but it is in all ways equivalent to *.
  1291.    EXPR   -->   EXPR / EXPR
  1292.       Both instances of EXPR must evaluate to numbers.   The value
  1293.       is the result of division and is of type floating_point.
  1294.    EXPR   -->   EXPR div EXPR
  1295.       Both instances  of EXPR must  evaluate to  integer, and  the
  1296.       second must  be non-zero.    The value  is integer  division
  1297.       defined by the following two relations,
  1298.                   (adiv b)?b+ (a modb)= a   for b > 0
  1299.                   adiv (?b)= ?(a div b)     for b < 0 .
  1300.  
  1301.  
  1302.    EXPR   -->   EXPR mod EXPR
  1303.       Both instances  of EXPR  must evaluate  to  integer and  the
  1304.       second must be non-zero.   The result is the remainder,  and
  1305.       the following condition is always satisfied,
  1306.                              0 <a modb < jbj.
  1307.    EXPR   -->   EXPR ** EXPR
  1308.       The values  of the  two expressions must  be numbers.    The
  1309.       operation is exponentiation.
  1310.    EXPR   -->   EXPR with EXPR
  1311.       The value of the first EXPR  must be a set or tuple.   If it
  1312.       is a set, the value is that set with the value of the second
  1313.       EXPR added  as an  element.   If it  is a  tuple, the  value
  1314.       of the second  EXPR is  assigned to the  value of the  first
  1315.       component after the last defined component of the tuple.
  1316.  
  1317.    EXPR   -->   EXPR less EXPR
  1318.       The value of  the first EXPR must  be a set.   The value  is
  1319.       that set with  the value of the  second EXPR removed, if  it
  1320.       was present; the value of the first EXPR, if  the second was
  1321.       not present.
  1322.    EXPR   -->   EXPR = EXPR
  1323.       The test for equality of any two ISETL values.
  1324.  
  1325.  
  1326. 6.9 Expressions                                                 31
  1327.  
  1328.    EXPR   -->   EXPR /= EXPR
  1329.       Negation of EXPR=EXPR.
  1330.    EXPR   -->   EXPR < EXPR
  1331.    EXPR   -->   EXPR > EXPR
  1332.    EXPR   -->   EXPR <= EXPR
  1333.  
  1334.    EXPR   -->   EXPR >= EXPR
  1335.       For all the above inequalities, both instances of  EXPR must
  1336.       evaluate to the same type,  which must be number  or string.
  1337.       For numbers, this  is the test  for the standard  arithmetic
  1338.       ordering;  for strings,  it is  the  test for  lexicographic
  1339.       ordering.
  1340.    EXPR   -->   EXPR in EXPR
  1341.       The second EXPR must be a  set, tuple, or string.   For sets
  1342.       and tuples, this is the test for membership of  the first in
  1343.       the second.  For strings, it is the test for substring.
  1344.    EXPR   -->   EXPR notin EXPR
  1345.       Negation of EXPR in EXPR.
  1346.    EXPR   -->   EXPR subset EXPR
  1347.       Both instances of EXPR must be  sets.  This is the  test for
  1348.       the value of the first EXPR  to be a subset of the  value of
  1349.       the second EXPR.
  1350.  
  1351.    EXPR   -->   EXPR and EXPR
  1352.       Logical conjunction.  Both instances of EXPR should evaluate
  1353.       to a  Boolean.   If  the left  operand is  false, the  right
  1354.       operand is  not  evaluated.    Actually returns  the  second
  1355.       argument, if the first is  true.  While the user  may depend
  1356.       on the  left-to-right evaluation  order,  it is  recommended
  1357.       that  they not  depend  on  the  behavior  when  the  second
  1358.       argument is not Boolean.
  1359.    EXPR   -->   EXPR or EXPR
  1360.       Logical disjunction.  Both instances of EXPR should evaluate
  1361.       to a  Boolean.    If the  left operand  is true,  the  right
  1362.       operand is  not  evaluated.    Actually returns  the  second
  1363.       argument, if the first is false.  While the  user may depend
  1364.       on the  left-to-right evaluation  order,  it is  recommended
  1365.       that  they not  depend  on  the  behavior  when  the  second
  1366.       argument is not Boolean.
  1367.  
  1368.  
  1369. 32                               6 THE ISETL GRAMMAR --- ANNOTATED
  1370.  
  1371.    EXPR   -->   EXPR impl EXPR
  1372.       Logical implication.   Both instances of EXPR must  evaluate
  1373.       to a Boolean.
  1374.    EXPR   -->   EXPR iff EXPR
  1375.       Logical equivalence.  Both instances of EXPR should evaluate
  1376.       to a Boolean.  It actually checks for equality,  like =, but
  1377.       it has a different precedence.   It is recommended  that the
  1378.       user not  depend on iff  to work  with arguments other  than
  1379.       Booleans.
  1380.    EXPR   -->   % BINOP EXPR
  1381.       EXPR must evaluate to a set, tuple, or string.  Say that the
  1382.       elements in EXPR are  x1, x2,...,xN (N=#EXPR). If N=0,  then
  1383.       the value  is OM.   If  N=1, then  the value  is the  single
  1384.       element.  Otherwise, %? EXPR equals
  1385.                           x1 ?  x2 ? ??? ? xN
  1386.       associating to the left.
  1387.       If EXPR is a set, then the selection of elements  is made in
  1388.       arbitrary order, otherwise  it is made  in the order of  the
  1389.       components of EXPR.
  1390.  
  1391.    EXPR   -->   EXPR % BINOP EXPR
  1392.       The second instance of EXPR  must evaluate to a set,  tuple,
  1393.       or string.   If the  first EXPR is  a, BINOP is  ?, and  the
  1394.       values in the  second are x1,  x2,..,xN  as above, then  the
  1395.       value is:
  1396.                         a ?  x1 ? x2 ?  ???? xN
  1397.       associating to the left.
  1398.    EXPR   -->   EXPR ? EXPR
  1399.       The value of the first EXPR, if it is not  OM; otherwise the
  1400.       value of the second EXPR.
  1401.    EXPR   -->   exists ITER-LIST | EXPR
  1402.       EXPR must evaluate to a Boolean.  If  ITER-LIST generates at
  1403.       least one instance in which EXPR evaluates to true, then the
  1404.       value is true; otherwise it is false.
  1405.  
  1406.    EXPR   -->   forall ITER-LIST | EXPR
  1407.       EXPR  must  evaluate to  a  Boolean.     If  every  instance
  1408.       generated by ITER-LIST is such that EXPR evaluates  to true,
  1409.       then the value is true; otherwise it is false.
  1410.  
  1411.  
  1412. 6.10 Function Constants                                         33
  1413.  
  1414.    EXPR   -->   EXPR where DEFNS end
  1415.       The  value  is  the  value  of  the  EXPR  preceding  where,
  1416.       evaluated in  the current environment  with the  IDs in  the
  1417.       DEFNS  added to  the  environment  and  initialized  to  the
  1418.       corresponding EXPRs.   The  scope of the  IDs is limited  to
  1419.       the where expression.   The DEFNS can modify IDs  defined in
  1420.       earlier DEFNS in the same where expression.
  1421.    EXPR   -->   EXPR @ EXPR
  1422.       The first  expression must be  an integer  i and the  second
  1423.       a tuple T.   The  result is a tuple  consisting of the  same
  1424.       sequence as T, but with the first index being i.
  1425.  
  1426.    BINOP   -->   ``Any binary operator  or an ID or expression  in
  1427. parentheses whose value is  a function of two parameters.   The ID
  1428. and parenthesized expression may be preceded by a period.''
  1429.       The acceptable binary  operators are:  +,  -, *, **,  union,
  1430.       inter, /, div, mod, with, less, and, or, impl.
  1431.  
  1432.    DEFNS   -->   ``Zero  or  more  instances of  DEFN.  The  final
  1433. semicolon is optional.''
  1434.  
  1435.    DEFN   -->   BOUND := EXPR ;
  1436.  
  1437.    DEFN   -->   ID SELECTOR := EXPR ;
  1438.  
  1439.    EXPR-LIST   -->   ``One or more instances of EXPR  separated by
  1440. commas.''
  1441.  
  1442.  
  1443. 6.10 Function Constants
  1444.    FUNC-CONST   -->   FUNC-HEAD LOCALS VALUES STMTS end
  1445.       This  is  the syntax  for  user-defined  funcs.     One  may
  1446.       optionally close with  end func.   VALUES and LOCALS may  be
  1447.       repeated or omitted and appear in any order.
  1448.       See return on page 20.
  1449.  
  1450.    FUNC-CONST   -->   :  ID-LIST OPT-PART -> EXPR :
  1451.       An abbreviation for func(  ID-LIST OPT-PART ); return  EXPR;
  1452.       end
  1453.  
  1454.  
  1455. 34                               6 THE ISETL GRAMMAR --- ANNOTATED
  1456.  
  1457.    FUNC-HEAD   -->   func ( ID-LIST OPT-PART ) ;
  1458.       In this case, there are  parameters.  The parameters  in the
  1459.       OPT-PART receive the value om if there are  no corresponding
  1460.       arguments.
  1461.    FUNC-HEAD   -->   func ( OPT-PART ) ;
  1462.       In this case, there are no required parameters.
  1463.  
  1464.    OPT-PART   -->   opt ID-LIST
  1465.       ``May be omitted.''
  1466.  
  1467.    LOCALS   -->   local ID-LIST ;
  1468.  
  1469.    VALUES   -->   value ID-LIST ;
  1470.  
  1471.    ID-LIST   -->   ``One  or  more instances  of ID  separated  by
  1472. commas.''
  1473.  
  1474.  
  1475.                                                                 35
  1476.  
  1477. 7 Pre-defined Functions
  1478. 7.1 Functions on Integers
  1479.  
  1480. In each of the following, EXPR must evaluate to integer.
  1481.  
  1482.   1. even(EXPR) --- Is EXPR even?
  1483.   2. odd(EXPR) --- Is EXPR odd?
  1484.  
  1485.   3. float(EXPR)   ---   The   value   of   EXPR    converted   to
  1486.      floating_point.
  1487.  
  1488.   4. char(EXPR)  ---  The  one-character  string   whose  (machine
  1489.      dependent) index is the value of EXPR.
  1490.  
  1491.  
  1492. 7.2 Functions on Floating Point Numbers
  1493. In each of the following, EXPR must evaluate to floating_point.
  1494.  
  1495.   1. ceil(EXPR) ---  The  smallest integer  not smaller  than  the
  1496.      value of EXPR.
  1497.  
  1498.   2. floor(EXPR)  --- The  largest  integer not  larger  than  the
  1499.      value of EXPR.
  1500.   3. fix(EXPR) ---  The same as  floor(EXPR) if  EXPR>=0, and  the
  1501.      same as ceil(EXPR) if the value of EXPR<=0.   In other words,
  1502.      the fractional part is discarded.
  1503.  
  1504.  
  1505. 7.3 Functions on Sets
  1506.  
  1507. In each of following, EXPR must evaluate to a set.
  1508.  
  1509.   1. pow(EXPR) --- The set of all subsets of the value of EXPR.
  1510.   2. npow(EXPR,EXPR) --- One  EXPR must be a  set and the other  a
  1511.      non-negative integer.    The set of  all subsets  of the  set
  1512.      whose cardinality is equal to the integer.
  1513.  
  1514.  
  1515. 36                                         7 PRE-DEFINED FUNCTIONS
  1516.  
  1517. 7.4 Functions on Maps
  1518. In each of the following, EXPR must evaluate to a map.
  1519.  
  1520.   1. domain(EXPR) ---  The set of  all values  that appear as  the
  1521.      first component of an element of the value of EXPR.
  1522.   2. image(EXPR) ---  The set  of all  values that  appear as  the
  1523.      second component of an element of the value of EXPR.
  1524.  
  1525.  
  1526. 7.5 Standard Mathematical Functions
  1527.  
  1528.   1. Each  of  the   following  takes  a  single   floating_point
  1529.      argument.  The  result is a floating_point  approximation to
  1530.      the value of  the corresponding mathematical  function.
  1531.      exp, ln, log,  sqrt, sin, cos,  tan, asin, acos, atan,  sinh,
  1532.      cosh, tanh, asinh, acosh, atanh.
  1533.   2. In each  of  the following,  EXPR  must evaluate  to  integer
  1534.      or  floating_point.     The  result  is  the  value  of  the
  1535.      mathematical function in the same type as the value of EXPR.
  1536.  
  1537.      (a) sgn(EXPR) ---  If EXPR is  positive, then  1 ; if EXPR  is
  1538.          zero, then 0 ; otherwise ?1 .
  1539.      (b) random(EXPR)  ---  The value  is  a  number  selected  at
  1540.          random  in the  interval from  0 to  the  value of  EXPR,
  1541.          inclusive.    There has  been no  statistical study  made
  1542.          of  the generators.    Don't depend  on  them for  highly
  1543.          sensitive work.
  1544.      (c) randomize(EXPR)  ---   This  resets  the  random   number
  1545.          generator.  EXPR should be an integer.   This may be used
  1546.          to select a new sequence of random numbers.
  1547.  
  1548.   3. In each  of  the following,  both  occurrences of  EXPR  must
  1549.      evaluate to  a  number  or string.     The result  is  always
  1550.      one of  the two  EXPR,  according to  the usual  mathematical
  1551.      definition.
  1552.  
  1553.      (a) max(EXPR,EXPR)
  1554.      (b) min(EXPR,EXPR)
  1555.  
  1556.  
  1557. 7.6 Type Testers                                                37
  1558.  
  1559. 7.6 Type Testers
  1560. In each of the following, the value of EXPR can  be any ISETL data
  1561. type.   The function is the test  for the value of EXPR  being the
  1562. type indicated.
  1563.  
  1564.   1. is_atom(EXPR)
  1565.  
  1566.   2. is_boolean(EXPR)
  1567.   3. is_defined(EXPR) --- Negation of is_om.
  1568.  
  1569.   4. is_file(EXPR)
  1570.  
  1571.   5. is_floating(EXPR)
  1572.   6. is_func(EXPR)
  1573.  
  1574.   7. is_integer(EXPR)
  1575.  
  1576.   8. is_map(EXPR)
  1577.   9. is_number(EXPR) --- true for integer and floating_point.
  1578.  
  1579.  10. is_om(EXPR)
  1580.  
  1581.  11. is_set(EXPR)
  1582.  12. is_string(EXPR)
  1583.  
  1584.  13. is_tuple(EXPR)
  1585.  
  1586.  
  1587. 7.7 Input/Output Functions
  1588.   1. In  each of  the  following  functions,  the  value  of  EXPR
  1589.      must  be   a  string   that   is  a   file  name   consistent
  1590.      with  the  operating  system's  naming  conventions.      The
  1591.      value  of  the function  has  ISETL  type  file  and  may  be
  1592.      used  in read...  from..,  readf... from...,  print... to...,
  1593.      printf...to..., and the function eof to refer to that file.
  1594.  
  1595.  
  1596. 38                                         7 PRE-DEFINED FUNCTIONS
  1597.  
  1598.      (a) openr(EXPR) ---  If the file named  by the value of  EXPR
  1599.          exists, then it is  opened for reading, and the  value of
  1600.          the function  is of  type file.    If the  file named  by
  1601.          the value of EXPR  does not exist, then the value  of the
  1602.          function is OM.
  1603.          A special  case is  the file  named "CONSOLE".    Opening
  1604.          "CONSOLE" for  reading provides  a way to  read from  the
  1605.          console,  even  if  you are  currently  reading  from  an
  1606.          include file.   If you have  directed stdin from a  file,
  1607.          it  may read  from that  file  or it  may read  from  the
  1608.          console; this is machine dependent.
  1609.      (b) openw(EXPR) ---  If the file named  by the value of  EXPR
  1610.          does  not exist,  then  it is  created by  the  operating
  1611.          system externally  to ISETL.    This file  is opened  for
  1612.          writing from the  beginning, so that anything  previously
  1613.          in the file is  destroyed.  The value of the  function is
  1614.          of type file.
  1615.      (c) opena(EXPR)  --- The  same  as openw(EXPR),  except  that
  1616.          if  the  file exists  its  contents  are  not  destroyed.
  1617.          Anything  that is  written is  added to  the  end of  the
  1618.          file.
  1619.  
  1620.   2. In the  following  function, the  value of  EXPR  must be  of
  1621.      type file.    The file  specified  by this  value is  closed.
  1622.      Output files must be closed to guarantee that  all output has
  1623.      been stored by  the operating system.   All files are  closed
  1624.      automatically when  ISETL  is exited.    There  is usually  a
  1625.      system-imposed limit on the number of files that  may be open
  1626.      at one time,  however, so  it is a good  idea to close  files
  1627.      when finished using them.
  1628.  
  1629.      (a) close(EXPR) --- The value of the function is OM.
  1630.  
  1631.   3. In the following function the  value of EXPR must be  of type
  1632.      file.
  1633.  
  1634.      (a) eof(EXPR) ---  Test for having  read past  the end of  an
  1635.          external file.
  1636.  
  1637.  
  1638. 7.8 Miscellaneous                                               39
  1639.  
  1640. 7.8 Miscellaneous
  1641.   1. abs(EXPR)  ---   If  the   value  of  EXPR   is  integer   or
  1642.      floating_point,  then  the  value of  the  function  is  the
  1643.      standard absolute value.
  1644.  
  1645.   2. ord(EXPR) --- The inverse of char.  EXPR must be  a string of
  1646.      length 1.
  1647.   3. arb(EXPR) --- An  element of EXPR  selected arbitrarily.   If
  1648.      the value of  EXPR is empty, then  the value of the  function
  1649.      is OM.  EXPR may be a set, tuple, or string.
  1650.  
  1651.   4. random(EXPR) ---  An element  of EXPR  selected with  uniform
  1652.      probability.  If the  value of EXPR is empty, then  the value
  1653.      of the function is OM.  EXPR may be a set, tuple, or string.
  1654.  
  1655.   5. max_line(EXPR) ---  EXPR must be  an integer.   The  maximum
  1656.      number of  columns used  when pretty-printing is  set to  the
  1657.      value of EXPR.
  1658.   6. system(EXPR) ---  EXPR  must be  a  string.   The  string  is
  1659.      passed to the operating system as a command line.   Available
  1660.      under Unix, VMS, and MSDOS.
  1661.  
  1662.   7. precision(EXPR) ---  EXPR  must be  an integer.    This  sets
  1663.      the number  of  decimal  places shown  by  print.    If  EXPR
  1664.      is negative,  it indicates that  print should use  scientific
  1665.      notation.
  1666.  
  1667.   8. video(EXPR) --- MSDOS only.   EXPR must  be a boolean.   This
  1668.      controls how  the screen is  managed under MSDOS.  Generally,
  1669.      true is faster output, and  false is less likely to  run into
  1670.      trouble with compatibility questions.   Also controled by  -v
  1671.      on the command line.  See section 9.1.
  1672.  
  1673. 7.9 Tuple
  1674.   1. lo(EXPR) --- EXPR must be a tuple.  Returns the  low bound of
  1675.      the tuple.
  1676.  
  1677.   2. hi(EXPR) --- EXPR must  be a tuple.   Returns the high  bound
  1678.      of the tuple.
  1679.  
  1680.  
  1681. 40                                              8 PRECEDENCE RULES
  1682.  
  1683.   3. origin(EXPR) --- EXPR must be  an integer.  Sets  the default
  1684.      lower bound for tuples.
  1685.  
  1686.  
  1687. 8 Precedence Rules
  1688.    ? Operators  are  listed   from  highest  priority  to   lowest
  1689.      priority.
  1690.  
  1691.    ? Operators are left associative unless otherwise indicated.
  1692.  
  1693.    ? ``nonassociative'' means  that you cannot  use two  operators
  1694.      on that line without parentheses.
  1695.  
  1696.                         anything that is a call to a function
  1697.    CALL                 --- func, tuple, string, map, etc.
  1698.    # - +                unary operators
  1699.    ?                    nonassociative
  1700.    %                    nonassociative
  1701.    **                   right associative
  1702.    * / mod div inter
  1703.    + - with less union
  1704.    .ID                  infix use of binary function
  1705.    in notin subset
  1706.    < <= = /= > >=       nonassociative
  1707.    not                  unary
  1708.    and
  1709.    or
  1710.    impl
  1711.    iff
  1712.    exists forall
  1713.    where
  1714.  
  1715.  
  1716.                                                                 41
  1717.  
  1718. 9 Directives
  1719. 9.1 Brief Descriptions
  1720.  
  1721. There are  a number of  directives that can be  given to ISETL  to
  1722. modify its behavior.
  1723.    On the command line, the following switches  control aspects of
  1724. ISETL.
  1725.  
  1726. -d indicates direct input.   This suppresses the  interactive line
  1727.      editor or the screen editor in MSDOS.
  1728. -e implies -d and provides the !edit directive described below.
  1729.  
  1730. -s indicates silent  mode.   In silent  mode, the  header and  all
  1731.      prompts are suppressed.
  1732.  
  1733. -v (MSDOS only) controls the  initial value of video.  -v  sets it
  1734.      to safe  (on all  PC compatibles),  but slow  (on most  video
  1735.      boards).
  1736. The rest of the directives  are !  commands.  [ a |  b ] indicates
  1737. a choice between a and b.
  1738.  
  1739. 9.1.1 Commands
  1740.  
  1741.    ? !quit --- Exit ISETL.
  1742.  
  1743.    ? !include   <filename>   ---   Replace   <filename>   with   a
  1744.      file/pathname  according  to  the  rules  of  your  operating
  1745.      system.  ISETL will insert your file.
  1746.    ? !clear ---  Throw  away all  input back  to  the last  single
  1747.      prompt.
  1748.  
  1749.    ? !edit --- Edit all the input back to the  last single prompt.
  1750.      Unavailable on systems with the interactive line editor.
  1751.  
  1752.    ? !memory [nnn] --- Change the  legal upper bound to nnn.   May
  1753.      not be lower  than the currently  allocated memory.   Without
  1754.      nnn, shows how much memory has been allocated.
  1755.  
  1756.  
  1757. 42                                                    9 DIRECTIVES
  1758.  
  1759.    ? !allocate nnn --- Increase the currently allocated  memory to
  1760.      nnn.   Will not exceed  the upper bound  set by !memory,  nor
  1761.      the actual limits of the machine.
  1762.    ? !record  [  file-name  ]    ---  Begins  recording  input  to
  1763.      ``file-name''.   This lets you  experiment and keep a  record
  1764.      of the work performed.
  1765.  
  1766.    ? !system  command-line  ---  Sends  the  command-line  to  the
  1767.      system for execution.  Not available on the Macintosh.
  1768.  
  1769.    ? !ids --- Lists all identifiers that have been defined.
  1770.    ? !oms --- Lists all  identifiers that have been used,  but not
  1771.      defined.
  1772.  
  1773.    ? !alias  id   command-line  ---   Makes   !id  equivalent   to
  1774.      !command-line.
  1775.  
  1776.    ? !version --- Prints version information for ISETL.
  1777.  
  1778. 9.1.2 Toggles
  1779. Toggles take arguments  on or off.   Without arguments, they  echo
  1780. the toggle's current state.
  1781.  
  1782.    ? !verbose --- Controls the  amount of information provided  by
  1783.      runtime error messages.  See section 11.  Default is off.
  1784.  
  1785.    ? !echo  ---  When  on,   all  input  is  echoed.      This  is
  1786.      particularly useful when trying to find a syntax  error in an
  1787.      !include file or  input for a  read.  It  is also useful  for
  1788.      pedagogical purposes, as it  can be used to  interleave input
  1789.      and output.
  1790.    ? !code --- When on, you get a pseudo-assembly  listing for the
  1791.      program.  Default is off.
  1792.  
  1793.    ? !trace ---  When on, you  get an execution  trace, using  the
  1794.      same notation as !code.  When desperate, this can  be used to
  1795.      trace the  execution of your  program.   Really intended  for
  1796.      debugging ISETL.  Default is off.
  1797.  
  1798.  
  1799. 9.2 !clear and !edit                                            43
  1800.  
  1801.    ? !source ---  Saves source for  debugging.   See !pp,  !stack,
  1802.      and !slow.
  1803.    ? !stack --- Show calls when errors occur.
  1804.  
  1805. 9.1.3 Debugging
  1806.  
  1807.   1. !watch list-of-ids  --- Traces assignment  and evaluation  of
  1808.      ids.
  1809.   2. !unwatch list-of-ids --- Turns off tracing for ids.
  1810.  
  1811.   3. !pp id [ file-name ]  --- Prints the source for  function id.
  1812.      When present,  output goes  to file-name;  otherwise,  output
  1813.      goes to last file.   !pp returns the file to  stdout (usually
  1814.      the screen).
  1815.   4. !slow  ---   Execution  steps   by   source  lines.       See
  1816.      section 9.1.3.
  1817.  
  1818.   5. !fast --- Return to normal execution speed.
  1819.  
  1820.    When the system  is stopped for  debugging, in the !slow  mode,
  1821. you get the ?> prompt.  Responses at this point are:
  1822.    f --- go to fast mode.
  1823.  
  1824.    l --- leap mode (calls are executed as one step).
  1825.    c --- crawl mode (trace execution within calls).
  1826.  
  1827.    e --- evaluate.  Enter an expression at the !  prompt.
  1828.  RET --- Execute the next step.
  1829.  
  1830.  
  1831. 9.2 !clear and !edit
  1832.   1. The  user can  edit6  whatever  has been  entered  since  the
  1833.      beginning of  the current  syntactic object,  in response  to
  1834.      a syntax  error  message,  or if  the  user wants  to  change
  1835.      something previously typed.   If  you prefer to start  again,
  1836.      ``!clear'' will  clear the  typing  buffer and  allow you  to
  1837.      start the input afresh.
  1838. ---------------------------
  1839.  6Turn this on with the -e switch.
  1840.  
  1841.  
  1842. 44                                                    9 DIRECTIVES
  1843.  
  1844.   2. When the editor  is invoked (by  typing ``!edit''), the  user
  1845.      is prompted for the string that is to be modified.   The user
  1846.      types the  desired string,  and  the editor  finds its  first
  1847.      occurrence in the lines being edited.
  1848.   3. The  user  is then  prompted  for  the  replacement  of  this
  1849.      string.  When it is entered, the change is made.
  1850.  
  1851.   4. The process  repeats until  the  user enters  a blank  search
  1852.      line, at which time control is returned to ISETL.
  1853.  
  1854.  
  1855. 9.3 !allocate and !memory
  1856. The !memory directive adjusts the upper limit  on permitted memory
  1857. allocation.  This is mainly to protect  mainframe systems, so that
  1858. one user doesn't use all the available space.
  1859.    The  !allocate  directive   increases  the  amount  of   memory
  1860. currently  available   for  ISETL   objects.      This  space   is
  1861. automatically increased  up to the  limit set  by !memory, but  by
  1862. allocating it early, some large programs may run more quickly.
  1863.    If you want  to grab as  much memory as possible,  particularly
  1864. on single user systems,  this is what we would recommend.   First,
  1865. determine  the  amount  of  memory  available,  by  attempting  to
  1866. allocate everything.    Then subtract  from that  10K for  ISETL's
  1867. scratch area  plus any other  space you may wish  to save for  use
  1868. by the !system directive.   You can then set the memory  limit and
  1869. pre-allocate in your  isetl.ini (or .isetlrc) files.
  1870.    See figure 4.   Having tried  to allocate 800K, there was  only
  1871. room for 500K.  Deciding to leave 200K for  other work, a limit of
  1872. 300K was placed on  ISETL, and 150K was pre-allocated.   The lines
  1873. below ``...'' are in another session, because one  cannot decrease
  1874. the GC (garbage collected) memory.
  1875.  
  1876.  
  1877. 9.4 !watch and !unwatch
  1878. The two  commands !watch  and !unwatch  control which  identifiers
  1879. are  traced during  execution.    Tracing  consists  of  reporting
  1880. assignments and function evaluation.
  1881.    An identifier is watched by the directive:
  1882.  
  1883.  
  1884. 9.5 !record                                                     45
  1885.  
  1886.                       !watch id id1 id2 id3
  1887. where ``id'' is  the name of the identifier  to be watched.   More
  1888. than one identifier may be listed, separated by blanks.
  1889.    While being watched,  any assignment to  a variable named  with
  1890. that identifier is echoed  on the standard output.   This includes
  1891. assignments to slices  and maps.  If  the identifier is used  as a
  1892. function (smap, mmap,  tuple, func), a line is  printed indicating
  1893. that  the expression  is  being evaluated  and  a second  line  is
  1894. printed reporting the value returned.
  1895.    It is  significant that  identifiers are  watched, rather  than
  1896. variables.  If i is being watched, then all  variables named i are
  1897. watched.
  1898.    You can stop watching an identifier with the directive:
  1899.  
  1900.                            !unwatch id
  1901.  
  1902.    See figure 5 for an example of the output.
  1903.  
  1904. 9.5 !record
  1905. The !record directive channels all input from  standard input into
  1906. a file.   This allows you to  capture your work and later  edit it
  1907. for including.
  1908.    A directive  of the form:   !record  test changes to  recording
  1909. on file  test.   If you  had been recording  elsewhere, the  other
  1910. file is  closed.   !record with no file  name turns off  recording
  1911. altogether.  The recording is appended to an existing file.
  1912.    By combining  this with  the !echo  directive,  one can  create
  1913. terminal sessions.
  1914.  
  1915. 9.6 !system
  1916.  
  1917. This allows  you to execute  one command  in the operating  system
  1918. without  leaving ISETL.    This feature  is not  available on  the
  1919. Macintosh version.  See section 9.3 for hints  on making sure that
  1920. there is enough room to invoke the command from the system.
  1921.    You could list your directory on MS-DOS using the command:
  1922.  
  1923.                            !system dir
  1924.  
  1925.  
  1926. 46                                                      10 EDITORS
  1927.  
  1928.    Assuming that  you had enough  memory, you  could escape to  an
  1929. editor, edit a file, exit the editor, and then include the file.
  1930.    If you type  !system by itself,  you will enter  a new copy  of
  1931. your operating system.  You can execute anything  that fits in the
  1932. remaining memory.
  1933.  
  1934. 10 Editors
  1935.  
  1936. The original view of ISETL was a program that  read lines of text,
  1937. recognizing programs  and expressions,  and then evaluating  them.
  1938. The introduction  of editors  adds a  second level  to this.    In
  1939. each of  the editors,  there is some  way to  send text to  ISETL.
  1940. This phrase refers to taking the text and treating  it as if those
  1941. lines had been typed directly in.
  1942.  
  1943. 10.1 MSDOS Screen Editor
  1944. In the  MSDOS editor, you  send lines to  ISETL by typing  RETURN.
  1945. The  text that  is  sent is  called  a region.    The  first  line
  1946. of  a region  is marked  on the  screen with  a highlighted  first
  1947. character;  this is called  the TAG.7  The last line  is the  line
  1948. containing the cursor.
  1949.    The TAG  is  automatically placed  on the  last line,  so  just
  1950. typing normally  will behave  as expected.   If  you want to  send
  1951. earlier lines, edit them  first, then TAG the first line  you wish
  1952. sent by typing ^ T, move to the last  line that you wish sent, and
  1953. type RETURN. Prompts at the beginning of a line are ignored.8
  1954.    To make it easy to  check a region, you can find TAG  by typing
  1955. ^ X (control-X).  This will exchange the cursor and TAG. Type ^  X
  1956. again to return.
  1957.    To make it easy  to find the last region  sent, type ^  B. This
  1958. finds the BOOK_MARK, which is left behind at the  old TAG after a
  1959. region is sent to ISETL.
  1960. ---------------------------
  1961.  7If  the  line  is  completely   empty.     the  whole   line  is
  1962. h8N.B.:htIf.you try to type a line starting with `>',  `?', or `!'
  1963. you must leave a blank in front of them  to prevent their removal.
  1964. Blanks are automatically inserted after the prompts.
  1965.  
  1966.  
  1967. 10.2 Mac Screen Editor                                          47
  1968.  
  1969.     Table 1:  Important keys for MSDOS Editor(^X = control-X)
  1970.  
  1971.     ESC             Get menu
  1972.     Arrow Keys      Motion
  1973.     INS             Break line
  1974.     DEL             Delete under
  1975.     Backspace       Delete left
  1976.     Home            Left of line
  1977.     End             Right of line
  1978.     PgUp (PgDn)     Up (down) 8 lines
  1979.     ^PgUp (^PgDn)   Top (bottom) of buffer
  1980.     Return (LF)     If below tag, execute; o.w.  insert return
  1981.     ^A              Mark previous region
  1982.     ^B              Go back to bookmark (previous tag)
  1983.     ^E              Erase current line
  1984.     ^L              Refresh screen
  1985.     ^T              Tag top of region
  1986.     ^X              Exchange tag and cursor
  1987.     ^Z              Escape to DOS. Use ``exit'' to return
  1988.  
  1989. Help is available through menu or F1.
  1990.  
  1991.    There is a menu  (ESC). You can execute commands from  the menu
  1992. by typing ESC followed by the capital letter in  the command or by
  1993. moving to the command with the arrows and then typing return.
  1994.    A  hint.    You  can read  a  file  that contains  prompts  and
  1995. then  execute it.    Note that  you cannot  !include  a file  with
  1996. prompts, because they  are not syntactically correct,  but prompts
  1997. are stripped from the beginning of the line  when the editor sends
  1998. lines to ISETL.
  1999.  
  2000.  
  2001. 10.2 Mac Screen Editor
  2002. The Macintosh  version has an  editor that needs no  introduction.
  2003. All  operations are  reachable  from  the menus,  and  follow  the
  2004. standard Macintosh usages.
  2005.    The only  unusual feature  is that highlighted  regions can  be
  2006. run --- sent to  the execution window and sent to ISETL  as input.
  2007.  
  2008.  
  2009. 48                                                      10 EDITORS
  2010.  
  2011.                  Table 2:  Menu for MSDOS Editor
  2012.  
  2013.           Copy region  Copies region  to the end  of the
  2014.                        buffer.
  2015.           Save region  Appends region to a  file.  Omits
  2016.                        prompts.
  2017.           Read file    Placed at end of buffer.
  2018.           save Buffer  Saves buffer, with prompts.
  2019.           Quit         Like !quit.
  2020.           buffer Info  Information  on  buffer size  and
  2021.                        cursor position.
  2022.           Help         Describes key maps.
  2023.  
  2024.  
  2025.  
  2026. You can run by:
  2027.  
  2028.    ? Typing RETURN,
  2029.  
  2030.    ? Selecting Run from the menu, or
  2031.    ? Typing clover-R.
  2032.  
  2033. In  addition, typing  RETURN on  the last  line  of the  Execution
  2034. window causes that line to be sent to ISETL.
  2035.  
  2036. 10.3 Interactive Line Editor (ILE)
  2037.  
  2038. 10.3.1 Brief description
  2039. The left and right arrows will move you  within a line, permitting
  2040. insertions of  characters.   delete removes  the character at  the
  2041. cursor, backspace deletes the  character left of the cursor.   The
  2042. interesting feature is that  the up arrow moves you back  thru the
  2043. last hundred  lines entered, with  down arrow moving you  forward.
  2044. You can't go past the last entered line.
  2045.    You need to use !clear  if you want to throw away  your current
  2046. input (since the last >) so that you can edit it.
  2047. Example:
  2048.  
  2049. >   a := b +
  2050.  
  2051.  
  2052. 10.3 Interactive Line Editor (ILE)                              49
  2053.  
  2054. >>       c +
  2055. >>  !clear
  2056. >            =up=>      c + =up=>  a := b +
  2057. >>           =up=> a := b + =up=>       c +  =edit=> c;
  2058. The  !clear had  ISETL  throw away  the  earlier input,  but  left
  2059. it for  subsequent editting.    =up=> means typing  the up  arrow,
  2060. followed by the new  value displayed on that line.   =edit=> means
  2061. editing the line to produce the desired result.
  2062.    Below is a complete description of the new editor.
  2063.  
  2064. 10.3.2 Default key bindings
  2065.  
  2066. The interactive line editor is an input  line editor that provides
  2067. both line  editing and a  history mechanism  to edit and  re-enter
  2068. previous lines.
  2069.    ISETL looks  in the ile initialization  file.   See page 4  for
  2070. more information.
  2071.    Not  everyone  wants  to   have  to  figure  out   yet  another
  2072. initialization  file  format  so we  provide  a  complete  set  of
  2073. default bindings for all its operations.
  2074.    The following table shows the default bindings of  keys and key
  2075. sequences provided  by ile.    These are  based on  the emacs  key
  2076. bindings for similar operations.
  2077.  
  2078.  
  2079. 50                                                      10 EDITORS
  2080.    Key         Effect                VMS differences
  2081.    del         delete char under
  2082.    ^A          start of line         undefined
  2083.    ^B          backward char
  2084.    ^E          end of line
  2085.    ^F          forward char
  2086.    ^K          erase to end of line
  2087.    ^L          retype line
  2088.    ^N          forward history
  2089.    ^P          backward history
  2090.    ^U          erase line
  2091.    ^V          quote
  2092.    ^X          delete char under
  2093.  
  2094.    delete      delete char under     delete char before
  2095.    back space  delete char before    start of line
  2096.    return      add to history
  2097.    line feed   add to history
  2098.    home        start of line         undefined
  2099.    end         end of line           undefined
  2100.  
  2101.    ^C          interrupt
  2102.    ^Z          end of file
  2103.    ^D          end of file
  2104.  
  2105.    left        backward char
  2106.    right       forward char
  2107.    up          backward history
  2108.    down        forward history
  2109.  
  2110. 10.3.3 Initialization File
  2111.  
  2112. The  ile  initialization   file  is  a  list  of   table  numbers,
  2113. characters,  and actions or  strings.   ile has  4 action  tables.
  2114. Each action table  contains an action or string for  each possible
  2115. character.   ile decides  what to do with  a character by  looking
  2116. it up in  the table and executing  the action associated with  the
  2117. character or by  passing the string one  character at a time  into
  2118. ile as if  it had been typed by the  user.  Normally only  table 0
  2119.  
  2120.  
  2121. 10.3 Interactive Line Editor (ILE)                              51
  2122.  
  2123. is  used.   The  escape actions  cause the  next  character to  be
  2124. looked  up in  a different  table.   The  escape  actions make  it
  2125. possible to map multiple character sequences to actions.
  2126.    By default,  all entries  in table  0 are bound  to the  insert
  2127. action, and all entries in the other tables are  bound to the bell
  2128. action.   User specified  bindings override these  defaults.   The
  2129. example in  Table 3  is an  initialization file that  sets up  the
  2130. same key and delimiter bindings as the ile default bindings.
  2131.    The first character  on each key binding  line is the index  of
  2132. the table  to place  the key  binding in.   Valid  values for  the
  2133. index are 0, 1, 2, and 3.
  2134.    The second  character on the  line is  either the character  to
  2135. bind or an indicator that tells how to find  out what character to
  2136. bind.   If the second character is  any character besides `^  ' or
  2137. `\' then the action is bound to that character.
  2138.    If the  second character  on the  line is  `^ '  then the  next
  2139. character is taken as the name of a control character.  So ^  H is
  2140. backspace and ^ [ is escape.
  2141.    If the  second character on  the line  is a  `\' and the  next
  2142. character is a digit between 0 and 7  the the following characters
  2143. are interpreted as an octal number that  indicates which character
  2144. to bind  the action to.   If the  character immediately after  the
  2145. `\'  is not  an octal  digit then  the action  is  bound to  that
  2146. character.  For example,  to get the `^ ' character you  would use
  2147. `\^ '.
  2148.    The next character  on the line is  always `='.  Following  the
  2149. equal sign is the name of an action or a string.   The actions are
  2150. defined in the following table.
  2151.  
  2152. 10.3.4 Actions
  2153. bell Send a bell (^  G) character to the terminal.   Hopefully the
  2154.      bell will ring.  This  action is a nice way to tell  the user
  2155.      that an invalid sequence of keys has been typed.
  2156.  
  2157. insert Insert the character  into the edit buffer.   If there  are
  2158.      already 75 characters in the buffer ile will  beep and refuse
  2159.      to put the character in the buffer.
  2160.  
  2161.  
  2162. 52                                                      10 EDITORS
  2163.  
  2164.  
  2165.      0\177=delete_char_under
  2166.      0^@=escape_3
  2167.      0^A=start_of_line
  2168.      0^B=backward_char
  2169.      0^C=pass_thru
  2170.      0^D=pass_thru
  2171.      0^E=end_of_line
  2172.      0^F=forward_char
  2173.      0^J=add_to_history
  2174.      0^H=delete_char
  2175.      0^K=erase_to_end_of_line
  2176.      0^L=retype_line
  2177.      0^M=add_to_history
  2178.      0^N=forward_history
  2179.      0^P=backward_history
  2180.      0^U=erase_line
  2181.      0^V=quote
  2182.      0^X=delete_char_under
  2183.      0^Z=pass_thru
  2184.      0^[=escape_1
  2185.  
  2186.      1[=escape_2
  2187.  
  2188.      2A=backward_history
  2189.      2B=forward_history
  2190.      2C=forward_char
  2191.      2D=backward_char
  2192.  
  2193.      3\107=start_of_line
  2194.      3\110=backward_history
  2195.      3\113=backward_char
  2196.      3\115=forward_char
  2197.      3\117=end_of_line
  2198.      3\120=forward_history
  2199.      3\123=delete_char_under
  2200.  
  2201.                   Table 3:  Example ile.ini file
  2202.  
  2203.  
  2204. 10.3 Interactive Line Editor (ILE)                              53
  2205.  
  2206. delete_char Delete  the character  directly to  the  left of  the
  2207.      cursor from the edit buffer.
  2208. delete_char_under Delete  the character  under the  cursor  from
  2209.      the edit buffer.
  2210.  
  2211. quote The next  character to come into  ile will be inserted  into
  2212.      the edit buffer.  This allows you to put  characters into the
  2213.      edit buffer that are bound to an action other than insert.
  2214.  
  2215. escape_1 Look up the next character in action table  1 instead of
  2216.      action table 0.
  2217. escape_2 Look up the next character in action table  2 instead of
  2218.      action table 0.
  2219.  
  2220. escape_3 Look up the next character in action table  3 instead of
  2221.      action table 0.
  2222.  
  2223. start_of_line Move the cursor to the left most  character in the
  2224.      edit buffer.
  2225. backward_char Move the cursor to the left one character.
  2226.  
  2227. end_of_line Move the cursor past the last character  in the edit
  2228.      buffer.
  2229.  
  2230. forward_char Move the cursor to the right one character.
  2231. add_to_history Add  the  contents of  the  edit  buffer  to  the
  2232.      history  buffer  and pass  the  line  along  to  the  program
  2233.      running under ile.
  2234.  
  2235. erase_line Clear the line.  Erase all characters on the line.
  2236.  
  2237. erase_to_end_of_line Delete  the character  under  the  cursor
  2238.      and all character  to the  left of the  cursor from the  edit
  2239.      buffer.
  2240. retype_line Retype  the  contents of  the  current  edit  buffer.
  2241.      This is  handy  when system  messages or  other  asynchronous
  2242.      output has garbled the input line.
  2243.  
  2244.  
  2245. 54                                                      10 EDITORS
  2246.  
  2247. forward_history Display the  next  entry in  the history  buffer.
  2248.      If you are already at  the most recent entry display  a blank
  2249.      line.   If you  try to go  forward past  the blank line  this
  2250.      command will beep at you.
  2251. backward_history Display  the  previous  entry  in   the  history
  2252.      buffer.  If there are no older entries in the buffer, beep.
  2253.  
  2254. 10.3.5 Strings
  2255.  
  2256. In  addition to  being able  to bind  a character  sequence to  an
  2257. action  ile allows  characters sequences  to be  bound to  strings
  2258. of characters.   When  a string is invoked  the characters in  the
  2259. string  are treated  as if  they  were typed  by the  user.    For
  2260. example, if the line:
  2261.  
  2262.                        0^G=ring^Ma^Mbell^M
  2263.    was in your  ile.ini file, typing  control G would cause  three
  2264. lines to be  typed as if the user  typed them.  Using  the default
  2265. bindings, unless there  is a ^ J or  ^ M in the string  the string
  2266. will be inserted in the current line but not  sent along until the
  2267. user actually presses return.
  2268.  
  2269. 10.3.6 Error Messages
  2270.  
  2271. When ile  encounters errors  it prints a  message and  terminates.
  2272. ile can print several  standard error message.  It can  also print
  2273. a few messages that are specific to ile.
  2274.  
  2275.    ? ile:  '=' missing on line #
  2276.      In a character binding  line you left out the  `=' character.
  2277.      Or, you did  something that confused the initialization  file
  2278.      reader into thinking there should be an `='  where you didn't
  2279.      think there should be one.
  2280.  
  2281.    ? ile:  error in initialization file on line #
  2282.      This means that  the first character  of a character  binding
  2283.      line wasn't a  newline or a  0, 1, 2,  or 3.   It could  also
  2284.      mean that the initialization file reader is confused.
  2285.  
  2286.  
  2287. 10.3 Interactive Line Editor (ILE)                              55
  2288.  
  2289.    A misspelled  action name in  an ile.ini will  be treated as  a
  2290. string.   This means that typing  the sequence of characters  that
  2291. should invoke the  action will actually cause the  misspelled name
  2292. to be inserted in the input line.
  2293.  
  2294. 10.3.7 Copyright
  2295. ile and  this documentation  was adapted from  the program  called
  2296. ile.     Permission to  modify  and  distribute  the  program  and
  2297. its  documentation is  granted, subject  to the  inclusion of  its
  2298. copyright notice, which  has been reproduced at the front  of this
  2299. manual.
  2300.  
  2301.  
  2302. 56                                               11 RUNTIME ERRORS
  2303.  
  2304. 11 Runtime Errors
  2305. Error messages  describe most problems  by printing the  operation
  2306. with the offending values of the arguments.
  2307.    If !source was on when  the program was read, you will  get the
  2308. source line  where the  error occurred.   If !stack  is on,  lines
  2309. containing the calls leading to this error will also be printed.
  2310.    One  possible  problem  is  that  some  values  are  very  big:
  2311. {1..1000} for  instance.   Therefore, there  are two forms  of
  2312. the error  messages, controlled  by the  !verbose directive.    By
  2313. default, verbose is off and large values  are represented by their
  2314. type.   The  directive !verbose  on results in  full values  being
  2315. printed.    !verbose  off returns  you  to short  messages.    See
  2316. figure 6 for an example.
  2317.  
  2318.  
  2319. 11.1 Fatal Errors
  2320. The  following  errors  cause ISETL  to  exit.     Generally  they
  2321. indicate  that  the  problem is  larger  than  ISETL  can  manage.
  2322. Please  report cases  where internal  limits are  exceeded to  the
  2323. author.
  2324.  
  2325. ------------------------------------------------------------------
  2326.  Allocated data memory exhausted   Use !memory to raise limit.
  2327.  Includes too deeply nested        Probably file includes itself.
  2328.  Out of parsing space              Internal limit exceeded.
  2329.  Parser out of memory              Internal limit exceeded.
  2330.  Too many locals                   Internal limit exceeded.
  2331.  Too many variables                Internal limit exceeded.
  2332.  
  2333.  
  2334. 11.2 Operator Related Messages                                  57
  2335.  
  2336. 11.2 Operator Related Messages
  2337. Most errors  print the  offending expression with  the values  (or
  2338. types)  of the  arguments.    A  few have  additional  information
  2339. attached.
  2340.  
  2341.  
  2342. -------------------------------------------------------------------
  2343.  +                     May refer to union.
  2344.  *                     May refer to inter.
  2345.  <relation>            Refers to any of the relational operators.
  2346.  Boolean expected      May occur in if, while, and,
  2347.                        or, ?, and iterators.
  2348.  Can't iterate over    Error in iterator.
  2349.  in LHS of assignment  Error in selector on LHS.
  2350.  Multiple images       Smap had multiple images.
  2351.  
  2352.  
  2353. 58                                               11 RUNTIME ERRORS
  2354.  
  2355. 11.3 General Errors
  2356. These  errors  do  not provide  context  by  printing  the  values
  2357. involved, but they are generally more specific.
  2358.            *         Used for self explanatory messages
  2359.            internal  Messages the user should never see
  2360.                      Please report to author.
  2361. -------------------------------------------------------------------------------
  2362.  
  2363.  Arithmetic error                      Relates to machine limits
  2364.  Bad arg to mcPrint                    internal
  2365.  Bad args in low,next..high            *
  2366.  Bad args in low..high                 *
  2367.  Bad format in readf                   *
  2368.  Bad mmap in iterator                  MMap iterator over non-map
  2369.  Can't mmap string                     Cannot perform selection in assignment
  2370.  Can't mmap tuple                      Cannot perform selection in assignment
  2371.  Cannot edit except at top level       Edit not permitted within
  2372.                                        an include
  2373.  Divide by zero                        *
  2374.  Exact format too big in readf         *
  2375.  Floating point error                  *
  2376.  Input must be an expression           *
  2377.  Internal object too large             *
  2378.  Iter_Next                            internal
  2379.  Nesting too deep for pretty printer.  *
  2380.  Only one level of selection allowed   See section 5
  2381.  Return at top level                   *
  2382.  RHS in mmap assignment must be set    *
  2383.  RHS in string slice assignment        *
  2384.    must be string
  2385.  RHS in tuple slice assignment         *
  2386.    must be tuple
  2387.  Return at top level                   *
  2388.  Slice lower bound too big             *
  2389.  Slice upper bound too big             *
  2390.  Stack Overflow                        *
  2391.  Stack Underflow                       *
  2392.  Too few arguments                     *
  2393.  Too many arguments                    *
  2394.  Wrong number of args                  *
  2395.  
  2396.  
  2397. 11.3 General Errors                                             59
  2398.  
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413.            >       !memory
  2414.            Current GC memory = 50060, Limit = 1024000
  2415.            >       !allocate 800000
  2416.            Current GC memory = 500600, Limit = 1024000
  2417.            ...
  2418.            >       !memory 300000
  2419.            Current GC memory = 50060, Limit = 300000
  2420.            >       !allocate 150000
  2421.            Current GC memory = 150180, Limit = 300000
  2422.  
  2423.                  Figure 4:  Finding memory limits
  2424.  
  2425.  
  2426. 60                                               11 RUNTIME ERRORS
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.               >       f := func(i);
  2436.                                return f(i-1)+f(i-2);
  2437.                            end;
  2438.               >       !watch f
  2439.               !'f' watched
  2440.               >       f(1) := 1;
  2441.               !  f(1) := 1;
  2442.  
  2443.               >       f(2) := 1;
  2444.               !  f(2) := 1;
  2445.  
  2446.               >       f(4);
  2447.               !  Evaluate:  f(4);
  2448.               !  Evaluate:  f(3);
  2449.               !  Evaluate:  f(2);
  2450.               !  Yields:  1;
  2451.               !  Evaluate:  f(1);
  2452.               !  Yields:  1;
  2453.               !  f returns:  2;
  2454.               !  Evaluate:  f(2);
  2455.               !  Yields:  1;
  2456.               !  f returns:  3;
  2457.               3;
  2458.  
  2459.                     Figure 5:  !watch examples
  2460.  
  2461.  
  2462. 11.3 General Errors                                             61
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.                   >       !verbose on
  2479.                   >       {1..3} + 5;
  2480.                   !  Error -- Bad arguments in:
  2481.                   {3, 1, 2} + 5;
  2482.  
  2483.                   >       !verbose off
  2484.                   >       {1..3} + 5;
  2485.                   !  Error -- Bad arguments in:
  2486.                   !Set!  + 5;
  2487.  
  2488.                     Figure 6:  Runtime errors
  2489.  
  2490.  
  2491. 62                                               11 RUNTIME ERRORS
  2492.  
  2493.  
  2494.                                                                 63
  2495.  
  2496. 12 The ISETL Grammar --- Compressed
  2497. 12.1 Input at the Prompt
  2498.  
  2499.    INPUT   -->   PROGRAM
  2500.    INPUT   -->   STMT
  2501.    INPUT   -->   EXPR ;
  2502.  
  2503. 12.2 Program
  2504.  
  2505.    PROGRAM   -->   program ID ; LOCALS VALUES STMTS end ;
  2506.  
  2507. 12.3 Statements
  2508.    STMT   -->   LHS := EXPR ;
  2509.    STMT   -->   EXPR ;
  2510.    STMT   -->   if EXPR then STMTS ELSE-IFS ELSE-PART end ;
  2511.  
  2512.        ELSE-IFS  -->   ``Zero or more repetitions of  ELSE-IF.''
  2513.  
  2514.        ELSE-IF  -->   elseif EXPR then STMTS
  2515.  
  2516.        ELSE-PART  -->   else STMTS
  2517.    STMT   -->   for ITERATOR do STMTS end ;
  2518.    STMT   -->   while EXPR do STMTS end ;
  2519.    STMT   -->   read LHS-LIST ;
  2520.    STMT   -->   read LHS-LIST from EXPR ;
  2521.    STMT   -->   readf PAIR-LIST ;
  2522.    STMT   -->   readf PAIR-LIST to EXPR ;
  2523.    STMT   -->   print EXPR-LIST ;
  2524.    STMT   -->   print EXPR-LIST to EXPR ;
  2525.    STMT   -->   printf PAIR-LIST ;
  2526.    STMT   -->   printf PAIR-LIST to EXPR ;
  2527.    STMT   -->   return ;
  2528.    STMT   -->   return EXPR ;
  2529.    STMT   -->   take LHS from LHS ;
  2530.    STMT   -->   take LHS frome LHS ;
  2531.    STMT   -->   take LHS fromb LHS ;
  2532.    STMT   -->   write PAIR-LIST ;
  2533.    STMT   -->   write PAIR-LIST to EXPR ;
  2534.    STMT   -->   writeln PAIR-LIST ;
  2535.  
  2536.  
  2537. 64                             12 THE ISETL GRAMMAR --- COMPRESSED
  2538.  
  2539.    STMT   -->   writeln PAIR-LIST to EXPR ;
  2540.    STMTS   -->    ``One or  more  instances  of  STMT.  The  final
  2541. semicolon is optional.''
  2542.    PAIR-LIST   -->   ``One or more instances of PAIR, separated by
  2543. commas.''
  2544.    PAIR   -->   EXPR : EXPR
  2545.    PAIR   -->   EXPR
  2546.  
  2547. 12.4 Iterators
  2548.  
  2549.    ITERATOR   -->   ITER-LIST
  2550.    ITERATOR   -->   ITER-LIST | EXPR
  2551.    ITER-LIST   -->   ``One or  more SIMPLE-ITERATORs separated  by
  2552. commas.''
  2553.    SIMPLE-ITERATOR   -->   BOUND-LIST in EXPR
  2554.    SIMPLE-ITERATOR   -->   BOUND = ID ( BOUND-LIST )
  2555.    SIMPLE-ITERATOR   -->   BOUND = ID { BOUND-LIST }
  2556.    BOUND-LIST   -->   ``One or more instances of  BOUND, separated
  2557. by commas.''
  2558.    BOUND   -->   ~
  2559.    BOUND   -->   ID
  2560.    BOUND   -->   [ BOUND-LIST ]
  2561.  
  2562.  
  2563. 12.5 Selectors
  2564.    SELECTOR   -->   ( EXPR-LIST )
  2565.    SELECTOR   -->   { EXPR-LIST }
  2566.    SELECTOR   -->   ( EXPR .. EXPR )
  2567.    SELECTOR   -->   ( .. EXPR )
  2568.    SELECTOR   -->   ( EXPR .. )
  2569.    SELECTOR   -->   ( )
  2570.  
  2571. 12.6 Left Hand Sides
  2572.  
  2573.    LHS-LIST   -->   ``One or more  instances of LHS, separated  by
  2574. commas.''
  2575.    LHS   -->   ID
  2576.    LHS   -->   LHS SELECTOR
  2577.    LHS   -->   [ LHS-LIST ]
  2578.  
  2579.  
  2580. 12.7 Expressions and Formers                                    65
  2581.  
  2582. 12.7 Expressions and Formers
  2583.    EXPR-LIST   -->   ``One or more instances of EXPR  separated by
  2584. commas.''
  2585.    EXPR   -->   ID
  2586.    EXPR   -->   INTEGER
  2587.    EXPR   -->   FLOATING-POINT
  2588.    EXPR   -->   STRING
  2589.    EXPR   -->   true
  2590.    EXPR   -->   false
  2591.    EXPR   -->   OM
  2592.    EXPR   -->   newat
  2593.    EXPR   -->   FUNC-CONST
  2594.    EXPR   -->   if EXPR then EXPR ELSE-IFS ELSE-PART end ;
  2595.    EXPR   -->   ( EXPR )
  2596.    EXPR   -->   [ FORMER ]
  2597.    EXPR   -->   { FORMER }
  2598.  
  2599.        FORMER  -->   ``Empty''
  2600.        FORMER  -->   EXPR-LIST
  2601.        FORMER  -->   EXPR .. EXPR
  2602.        FORMER  -->   EXPR , EXPR .. EXPR
  2603.        FORMER  -->   EXPR : ITERATOR
  2604.    EXPR   -->   # EXPR
  2605.    EXPR   -->   not EXPR
  2606.    EXPR   -->   + EXPR
  2607.    EXPR   -->   - EXPR
  2608.    EXPR   -->   EXPR SELECTOR
  2609.    EXPR   -->   EXPR . ID EXPR
  2610.    EXPR   -->   EXPR . (EXPR) EXPR
  2611.  
  2612.  
  2613. 66                             12 THE ISETL GRAMMAR --- COMPRESSED
  2614.  
  2615.    EXPR   -->   EXPR OP EXPR
  2616.       Possible operators (OP) are:
  2617.                             + - * / div mod **
  2618.                                  with less
  2619.                               = /= < > <= >=
  2620.                         union inter in notin subset
  2621.                              and or impl iff
  2622.    EXPR   -->   % BINOP EXPR
  2623.    EXPR   -->   EXPR % BINOP EXPR
  2624.    EXPR   -->   EXPR ? EXPR
  2625.    EXPR   -->   exists ITER-LIST | EXPR
  2626.    EXPR   -->   forall ITER-LIST | EXPR
  2627.    EXPR   -->   EXPR where DEFNS end
  2628.    EXPR   -->   EXPR @ EXPR
  2629.    BINOP   -->   ``Any binary operator  or an ID or expression  in
  2630. parentheses whose value is  a function of two parameters.   The ID
  2631. and parenthesized expression may be preceded by a period.''
  2632.       The acceptable binary  operators are:  +,  -, *, **,  union,
  2633.       inter, /, div, mod, with, less, and, or, impl.
  2634.    DEFNS   -->   ``Zero  or  more  instances of  DEFN.  The  final
  2635. semicolon is optional.''
  2636.    DEFN   -->   BOUND := EXPR ;
  2637.    DEFN   -->   ID SELECTOR := EXPR ;
  2638.  
  2639.  
  2640. 12.8 Function Constants
  2641.    FUNC-CONST   -->   FUNC-HEAD LOCALS VALUES STMTS end
  2642.    FUNC-CONST   -->   :  ID-LIST OPT-PART -> EXPR :
  2643.    FUNC-HEAD   -->   func ( ID-LIST OPT-PART ) ;
  2644.    FUNC-HEAD   -->   func ( OPT-PART ) ;
  2645.  
  2646.    OPT-PART   -->   opt ID-LIST
  2647.       ``May be omitted.''
  2648.    LOCALS   -->   local ID-LIST ;
  2649.    VALUES   -->   value ID-LIST ;
  2650.    ID-LIST   -->   ``One  or  more instances  of ID  separated  by
  2651. commas.''
  2652.  
  2653.  
  2654.  
  2655.  
  2656. Index
  2657.  
  2658. ?, 32, 66                           cos, 36
  2659. !  (directives), 16, 41
  2660. @, 33, 66                           DEFN, 33, 66
  2661. :=, 17, 63                          DEFNS, 33, 66
  2662. -, 28, 65                           difference (-) of two sets,
  2663. %, 32, 66                                   29, 66
  2664. .., 25--26, 64--65                  directives, 41
  2665. +, 28, 65                           div, 6, 29, 66
  2666. /, 29, 66                           do, 6, 18, 63
  2667. ~, 24, 64                           dollar sign, 6
  2668. abs, 39                             domain, 36
  2669. !alias, 42
  2670. !allocate, 42, 44                   !echo, 42
  2671. and, 6, 29, 66                      !edit, 41, 43
  2672. arb, 39                             else, 6, 18, 63
  2673. atom, 9                             ELSE-IF, 21, 63
  2674.                                     elseif, 6, 18, 63
  2675. BINOP, 33, 66                       ELSE-IFS, 21, 63
  2676. BOUND, 24, 64                       ELSE-PART, 21, 63
  2677. bound variable, 23                  empty
  2678. BOUND-LIST, 24, 64                      set (!1_2!, ;), 10
  2679.                                         tuple ([]), 11
  2680. call by value, 14                   end, 6, 18, 33, 63, 66
  2681. cardinality (#) of a set, 28,       eof, 38
  2682.         65                          equal, 29, 66
  2683. ceil, 35                            error messages, 56
  2684. char, 35                            even, 35
  2685. character set, 6                    exists, 6, 32, 66
  2686. !clear, 41, 43                      exit, 4
  2687. close, 38                           exponentiation (**), 29, 66
  2688. !code, 42                           EXPR, 27, 65
  2689. comments ($), 6                     EXPR-LIST, 33, 65
  2690. compound operator (%), 32, 66
  2691. concatenation (+)                   false, 6, 8, 27, 65
  2692.     string, 29, 66                  !fast, 43
  2693.     tuple, 29, 66                   file, 9
  2694. CONSOLE, 38                         fix, 35
  2695.  
  2696.                                 67
  2697.  
  2698.  
  2699. 68                                                           INDEX
  2700.  
  2701. float, 35                           Interactive Line Editor,
  2702. FLOATING-POINT, 27, 65                      48--55
  2703. floating-point number, 7            intersection (*, inter, \   ),
  2704. floor, 35                                   29--30, 66
  2705. for, 6, 18, 63                      is..., 37
  2706. forall, 6, 32, 66                   isetl.ini, 4, 44
  2707. FORMER, 25, 65                      .isetlrc, 4, 44
  2708. from, 6, 18, 20, 63                 ITERATOR, 23, 64
  2709. fromb, 6, 20, 63                    ITER-LIST, 24, 64
  2710. frome, 6, 20, 63
  2711. func, 6, 12--15, 34, 66
  2712. FUNC-CONST, 28, 33, 65--66          length (#)
  2713. FUNC-HEAD, 34, 66                       of a string, 28, 65
  2714. function, 12--15, 26                    of a tuple, 28, 65
  2715.     application, 25                 less, 6, 29, 66
  2716.     modified at a point, 15         LHS, 27, 64
  2717.     of several variables, 26        LHS-LIST, 27, 64
  2718. generalize operation, 32, 66        ln, 36
  2719. grammar, 16                         lo, 39
  2720.                                     local, 6
  2721. hi, 39                              LOCALS, 34, 66
  2722. hyperbolic functions, 36            log, 36
  2723.  
  2724. ID, 27, 65                          map, 12, 25
  2725. ID-LIST, 34, 66                     max, 36
  2726. !ids, 42                            max_line, 39
  2727. if, 6, 18, 63                       !memory, 44
  2728. iff, 6, 29, 66                      min, 36
  2729. ile.ini, 49                         mmap, 25
  2730. image, 36                           mod, 6, 29, 66
  2731. image, 25                           MSDOS, 39
  2732. impl, 6, 29, 66
  2733. in, 6, 24, 29, 64, 66               newat, 6, 28, 65
  2734. !include, 5, 41                     not, 6, 28, 65
  2735. INPUT, 17, 63                       notin, 6, 29, 66
  2736. INTEGER, 27, 65                     npow, 35
  2737. integer, 7                          number, 7
  2738. inter, 6, 29, 66
  2739.                                     odd, 35
  2740.  
  2741.  
  2742. INDEX                                                           69
  2743.  
  2744. of, 6                               scope, 14, 23
  2745. om, 6, 28, 65                       SELECTOR, 25, 64
  2746. !oms, 42                            set former, 10
  2747. opena, 38                           sgn, 36
  2748. openr, 38                           SIMPLE-ITERATOR, 24, 64
  2749. openw, 38                           sin, 36
  2750. opt, 6, 34, 66                      slice, 25
  2751. optional parameters, 14             !slow, 43
  2752. OPT-PART, 34, 66                    smap, 25
  2753. or, 6, 29, 66                       !source, 43
  2754. ord, 39                             sqrt, 36
  2755. origin, 40                          !stack, 43
  2756. PAIR, 21, 64                        STMT, 16--17, 63
  2757. PAIR-LIST, 21, 64                   STMTS, 21, 64
  2758. parameter, 14                       STRING, 27, 65
  2759. pow, 35                             subset, 6, 29, 66
  2760. !pp, 43                             !system, 42, 45
  2761. precedence rules, 40                system, 39
  2762. precision, 39                       take, 6, 20, 63
  2763. print, 6, 19, 39, 63                then, 6, 18, 63
  2764. printf, 6, 19                       to, 6, 19, 63
  2765. PROGRAM, 17, 63                     !trace, 42
  2766. program, 6                          trace, 43--44
  2767. prompts, 4                          transcendental functions, 36
  2768.                                     trig functions, 36
  2769. !quit, 4, 41                        true, 6, 8, 27, 65
  2770. quit, 4                             type test, 37
  2771.  
  2772. random, 36, 39                      union, 6, 29, 66
  2773. randomize, 36                       union (+, union, [   ), 29, 66
  2774. read, 6, 18, 63                     !unwatch, 43--44
  2775. readf, 6
  2776. !record, 42, 45                     value, 6
  2777. relational operators, 29, 66        value declaration, 15
  2778. replication (*)                     VALUES, 34, 66
  2779.     string, 29, 66                  !verbose, 42
  2780.     tuple, 29, 66                   !version, 42
  2781. return, 6, 12, 20, 63               video, 39
  2782.  
  2783.  
  2784. 70                                                           INDEX
  2785.  
  2786. !watch, 43--44
  2787. where, 6, 33, 66
  2788. while, 6, 18, 63
  2789. with, 6, 29, 66
  2790. write, 6
  2791. writeln, 6
  2792.