home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / ifp / part02 / manual
Encoding:
Text File  |  1987-07-05  |  58.3 KB  |  2,167 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.           Professional Workstation
  21.          Research Group Technical Report #7
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.          Illinois FP User's Manual
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.               Arch D. Robison
  37.            Department of Computer Science
  38.      University of Illinois at Urbana-Champaign
  39.            Urbana, Illinois 61801
  40.  
  41.               February 9, 1987
  42.  
  43.  
  44.  
  45.              _T_a_b_l_e _o_f _C_o_n_t_e_n_t_s
  46.  
  47. 1.  Overview ..........................................    1
  48. 2.  Prerequisites .....................................    2
  49. 2.1.  Organization ....................................    2
  50. 2.2.  Environment (UNIX) ..............................    3
  51. 2.3.  Environment (MSDOS) .............................    3
  52. 3.  Using IFP .........................................    4
  53. 3.1.  Starting IFP ....................................    4
  54. 3.2.  Creating and Editing Definitions ................    4
  55. 3.3.  Applying Functions ..............................    5
  56. 3.4.  Executing UNIX Commands .........................    5
  57. 3.5.  Executing MSDOS Commands ........................    6
  58. 4.  Language ..........................................    6
  59. 4.1.  Objects .........................................    6
  60. 4.2.  Functions .......................................    7
  61. 4.2.1.  Primitive Functions ...........................    9
  62. 4.2.1.1.  Structural Functions (/sys) .................   11
  63. 4.2.1.2.  Arithmetic (/math/arith) ....................   12
  64. 4.2.1.3.  Logic (/math/logic) .........................   14
  65. 4.2.1.4.  String Functions (/sys) .....................   16
  66. 4.2.1.5.  Miscellaneous Functions (/sys) ..............   16
  67. 4.2.2.  User Defined Functions ........................   19
  68. 4.2.3.  Functional Variables ..........................   20
  69. 4.3.  Functional Forms ................................   21
  70. 4.3.1.  Constant ......................................   21
  71. 4.3.2.  Selection .....................................   22
  72. 4.3.3.  Composition ...................................   22
  73. 4.3.4.  Construction ..................................   23
  74. 4.3.5.  Apply to Each .................................   23
  75. 4.3.6.  If-Then-Else ..................................   24
  76. 4.3.7.  Filter ........................................   24
  77. 4.3.8.  Right Insert ..................................   25
  78. 4.3.9.  While .........................................   26
  79. 4.3.10.  Fetch[8] .....................................   26
  80. 4.4.  Comments ........................................   27
  81. 4.5.  Syntax Summary ..................................   27
  82. 5.  IFP Graphics (optional)[9] ........................   27
  83. 5.1.  Coordinate System ...............................   28
  84. 5.2.  Display List Structure ..........................   28
  85. 5.2.1.  Polyline ......................................   28
  86. 5.2.2.  Color .........................................   29
  87. 5.2.3.  Transform .....................................   29
  88. 5.2.4.  Text ..........................................   29
  89. 6.  Debugging .........................................   30
  90. 7.  Differences between IFP and Backus' FP ............   31
  91. 7.1.  Domain ..........................................   31
  92. 7.2.  Functions .......................................   31
  93. 7.3.  Functional Forms ................................   31
  94. 7.4.  Syntax ..........................................   32
  95. 8.  Functional Programming Techniques .................   33
  96. 8.1.  Functional Programming Identities ...............   33
  97. 8.2.  Common Subfunctions .............................   34
  98. 8.3.  State Machines ..................................   34
  99. 8.4.  Tail Recursion ..................................   35
  100. 9.  Installation Notes ................................   35
  101. 9.1.  Machine Dependence ..............................   35
  102. 9.2.  Compiling Options ...............................   36
  103.  
  104.  
  105.                  i
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.           _I_l_l_i_n_o_i_s _F_P _0._5 _U_s_e_r_s _M_a_n_u_a_l[_1]
  114.  
  115.  
  116.  
  117. _1.  _O_v_e_r_v_i_e_w
  118.  
  119.  
  120.      Functional Programming (FP) [Bac78a] is a radically new
  121.  
  122. form  of  programming.  FP programs have neither the control
  123.  
  124. flow nor variables of Von-Neumann languages.   Instead  pro-
  125.  
  126. grams  are  directly constructed from smaller programs. As a
  127.  
  128. result, FP offers a new style of programming  with  numerous
  129.  
  130. advantages, including:
  131.  
  132.  
  133.             Modular Programming
  134.             Program Verification
  135.             Parallel Processing
  136.             Optimization
  137.  
  138.  
  139.  
  140.      IFP (Illinois Functional  Programming)  [Rob87a,Rob87b]
  141.  
  142. is  an interactive functional programming implementation for
  143.  
  144. UNIX and MSDOS systems.  The user may  interactively  create
  145.  
  146. and execute functional programs.  In addition to Backus' FP,
  147.  
  148. IFP has the following features:
  149.  
  150.  
  151.        Hierarchical and Modular Function Organization
  152.        Block-Structured Syntax
  153.        Error Explanations
  154.        Graphics Display List Processor[2]
  155.  
  156.  
  157. The interpreter is an order of magnitude  more  compact  and
  158. ____________________
  159.  
  160.    [1]Any resemblance to the real product  is  purely  coin-
  161. cidental.
  162.    [2]Once upon a time it worked.  The code has  since  then
  163. not  been maintained.  So it is not implemented in most ver-
  164. sions.
  165.  
  166.  
  167.  
  168.  
  169. February 9, 1987    IFP 0.5 Users Manual                   2
  170.  
  171.  
  172. faster than previous FP implementations.
  173.  
  174.  
  175. _2.  _P_r_e_r_e_q_u_i_s_i_t_e_s
  176.  
  177.  
  178.      The rest of the manual  assumes  the  reader  has  read
  179.  
  180. Backus'  original paper on FP.  [Bac78a] Other references on
  181.  
  182. FP [Bad83a,Dar82a] may be of help.  Additionally,  parts  of
  183.  
  184. the  manual  assume  the reader understands UNIX or MSDOS[3]
  185.  
  186. file structure and paths.
  187.  
  188.  
  189. _2._1.  _O_r_g_a_n_i_z_a_t_i_o_n
  190.  
  191.  
  192.      IFP organizes functions in a tree  structure  analogous
  193.  
  194. to  UNIX/MSDOS files.  In fact each function is a file.  For
  195.  
  196. UNIX systems, each user specifies the root (``IFP root'') of
  197.  
  198. their function tree.  Within IFP, paths specify a path rela-
  199.  
  200. tive to the IFP root.   The  IFP  root  is  set  by  a  UNIX
  201.  
  202. environment  variable.   For  MSDOS systems, the IFP root is
  203.  
  204. identical to the current drive root.   (see  ``Environment''
  205.  
  206. below).
  207.  
  208.  
  209.      Each node on the tree is either a  function  definition
  210.  
  211. (corresponding  to  a file), or a module (corresponding to a
  212.  
  213. directory).  A function may reference another function via a
  214.  
  215. path.
  216.  
  217.  
  218.      To avoid having to write out  the  entire  path  for  a
  219.  
  220. function  every time, IFP has a function identifier importa-
  221.  
  222. tion feature.  Functions from other modules may be  imported
  223.  
  224. into  a module.  Once imported, a function may be referenced
  225.  
  226.  
  227.  
  228.  
  229. February 9, 1987    IFP 0.5 Users Manual                   3
  230.  
  231.  
  232. as though it were defined in the module.
  233.  
  234.  
  235. _2._2.  _E_n_v_i_r_o_n_m_e_n_t (_U_N_I_X)
  236.  
  237.  
  238.      Before invoking IFP, two environment  variables  should
  239.  
  240. be set. The ``EDITOR'' variable should be set to the name of
  241.  
  242. your favorite editor.  The ``IFProot''  variable  should  be
  243.  
  244. set to the  absolute  path  of  your  ``IFP  root''.[3]  The
  245.  
  246. ``IFPprompt''  is  optional.   If  set,  it  changes the IFP
  247.  
  248. prompt.  The default prompt is ``ifp>  ''.   Normally  these
  249.  
  250. variables  will  be  set  by  your .login file.  Below is an
  251.  
  252. example of the commands which would appear  in  your  .login
  253.  
  254. file.
  255.  
  256.        setenv EDITOR = ``/usr/ucb/vi''
  257.        setenv IFProot = ``/mnt/bonzo/fproot''
  258.        setenv IFPprompt = ``ifp> ''
  259.  
  260.  
  261. _2._3.  _E_n_v_i_r_o_n_m_e_n_t (_M_S_D_O_S)
  262.  
  263.  
  264.      Before invoking IFP, two environment  variables  should
  265.  
  266. be  set.   The ``EDITOR'' and ``IFPDIR'' variables should be
  267.  
  268. set to the names of your favorite editor and directory  lis-
  269.  
  270. ters  respectively.   Normally  these  should be set by your
  271.  
  272. autoexec.bat file, e.g.:
  273.  
  274.             set EDITOR=C:ED.EXE
  275.             set IFPDIR=C:SD2.COM
  276.  
  277. Unlike the UNIX version, there is no IFProot variable.   The
  278.  
  279. ____________________
  280.  
  281.    Use the actual path,  not  a  symbolic  link.   When  IFP
  282. starts  up,  it assumes that the current directory path is a
  283. prefix of the IFP root path.
  284.  
  285.  
  286.  
  287.  
  288. February 9, 1987    IFP 0.5 Users Manual                   4
  289.  
  290.  
  291. root of the IFP file system  is  the  root  of  the  current
  292.  
  293. drive.
  294.  
  295.  
  296. _3.  _U_s_i_n_g _I_F_P
  297.  
  298.  
  299. _3._1.  _S_t_a_r_t_i_n_g _I_F_P
  300.  
  301.  
  302.      To start an IFP session, change  your  current  working
  303.  
  304. directory  to  a  directory  under your IFP root.  Then type
  305.  
  306. "ifp".  Your current  working  directory  becomes  your  IFP
  307.  
  308. current  working  module. When IFP is ready, it will respond
  309.  
  310. with the prompt ``ifp> ''.  To end  the  IFP  session,  type
  311.  
  312. control-D or enter the command ``exit''.
  313.  
  314.  
  315. _3._2.  _C_r_e_a_t_i_n_g _a_n_d _E_d_i_t_i_n_g _D_e_f_i_n_i_t_i_o_n_s
  316.  
  317.  
  318.      To edit an IFP definition, type the command:
  319.  
  320.              vi[4] foo
  321.  
  322. where foo is the name of the function  to  be  edited.   The
  323.  
  324. function  may be one local to the current working module, or
  325.  
  326. one that is imported into the current  working  module.   If
  327.  
  328. the  function  name is neither defined locally nor imported,
  329.  
  330. then it is assumed to be a new local function.  To delete an
  331.  
  332. IFP definition, type the command:
  333.  
  334.              rm[5] foo
  335.  
  336.  
  337. ____________________
  338.  
  339.    [4]If your editor is not ``vi'' (as specified by the last
  340. element  of  your  EDITOR  path),  replace  ``vi'' with your
  341. editor's name.  For MS-DOS, the command is always ``ed'', no
  342. matter what the editor is called.
  343.  
  344.  
  345.  
  346.  
  347. February 9, 1987    IFP 0.5 Users Manual                   5
  348.  
  349.  
  350. _3._3.  _A_p_p_l_y_i_n_g _F_u_n_c_t_i_o_n_s
  351.  
  352.  
  353.      To apply an FP function, type the command[6]:
  354.  
  355.           show object : function
  356.  
  357. The  interpreter  evaluates  the  result  of  applying   the
  358.  
  359. function  to  the object.  The result is then pretty-printed
  360.  
  361. at the terminal.  Below are some example inputs and outputs.
  362.  
  363. show <a b c> : reverse
  364.  
  365. <c b a>
  366.  
  367. show <1 2 3> : sum
  368.  
  369. 6
  370.  
  371. show <1 2 3> : EACH [id,id]|* END | sum     (* sum of squares *)
  372.  
  373. 14
  374.  
  375. show <1 2 3 4 5> : EACH iota END
  376.  
  377. <
  378.      <1>
  379.      <1,2>
  380.      <1,2,3>
  381.      <1,2,3,4>
  382.      <1,2,3,4,5>
  383. >
  384.  
  385. exit
  386.  
  387.  
  388. _3._4.  _E_x_e_c_u_t_i_n_g _U_N_I_X _C_o_m_m_a_n_d_s
  389.  
  390.  
  391.      If a command is not recognized by the IFP  interpreter,
  392.  
  393. then  it  is  passed  on to the UNIX shell ``sh''.  Commands
  394.  
  395. such as ``ls'' and  ``more''  work  as  expected.   Commands
  396.  
  397. which  change  environment  do  not  work  properly, as they
  398. ____________________
  399.  
  400.    [5]For MS-DOS, the command is ``del''.
  401.    [6]Some earlier versions (before 0.4, e.g. the  BYTE  BIX
  402. release) require a semicolon after the _f_u_n_c_t_i_o_n.
  403.  
  404.  
  405.  
  406.  
  407. February 9, 1987    IFP 0.5 Users Manual                   6
  408.  
  409.  
  410. change their environment (within ``sh'') but not  your  own.
  411.  
  412. For example, the ``cd'' command does not work.
  413.  
  414.  
  415. _3._5.  _E_x_e_c_u_t_i_n_g _M_S_D_O_S _C_o_m_m_a_n_d_s
  416.  
  417.  
  418.      The only two MSDOS command that can be run from  within
  419.  
  420. the  interpreter are ``dir'' and ``del''.  Some systems seem
  421.  
  422. to require ``dir/''.  I don't know why.
  423.  
  424.  
  425.  
  426. _4.  _L_a_n_g_u_a_g_e
  427.  
  428.  
  429.      IFP semantics  are  almost  identical  to  Backus'  FP,
  430.  
  431. though  the syntax is quite different. The IFP language con-
  432.  
  433. sists of objects, functions, and functional forms.  The sin-
  434.  
  435. gle operation is _a_p_p_l_y which maps a function and object into
  436.  
  437. a new object.
  438.  
  439.  
  440. _4._1.  _O_b_j_e_c_t_s
  441.  
  442.  
  443.      Objects in FP are either atoms, sequences,  or  _b_o_t_t_o_m.
  444.  
  445. The  latter  is  a special object which denotes an undefined
  446.  
  447. value.  Atoms  are  numbers,  strings,  or  boolean  values.
  448.  
  449. Strings  must  be quoted when they look like another kind of
  450.  
  451. atom or contain non-alphanumeric  characters.   Below  is  a
  452.  
  453. table of some typical atoms:
  454.  
  455.  
  456.        banana                 string
  457.        "The cat in the hat"   string (double quotes)
  458.        'hello world'          string (single quotes)
  459.        7                      number
  460.        3.1415                 number
  461.        1e6                    number (million)
  462.  
  463.  
  464.  
  465.  
  466. February 9, 1987    IFP 0.5 Users Manual                   7
  467.  
  468.  
  469.        "1.414"                string
  470.        t                      boolean true
  471.        f                      boolean false
  472.        "t"                    string
  473.  
  474.  
  475.  
  476.      Sequences are lists of zero or more objects  surrounded
  477.  
  478. by angle brackets.  Sequences are written as:
  479.  
  480.  
  481.                <x ,x ,...x >
  482.              1  2     n
  483. Below is table of some typical sequences:
  484.  
  485.  
  486.          <a,b,c>
  487.          <1 2 3 4 5 6>
  488.          <>
  489.          <<1 2 3> <apple banana> t>
  490.  
  491.  
  492. Either commas or spaces may be used to separate the elements
  493.  
  494. of a sequence.  The elements of the sequence may be any kind
  495.  
  496. of object except ``?'', and do not have to be  of  the  same
  497.  
  498. type.
  499.  
  500.  
  501.      IFP sequences have the _b_o_t_t_o_m _p_r_e_s_e_r_v_i_n_g [_B_a_c_7_8_a]  pro-
  502.  
  503. perty.   Any  sequence  containing  ``?'' is itself equal to
  504.  
  505. ``?''.
  506.  
  507.  
  508.  
  509. _4._2.  _F_u_n_c_t_i_o_n_s
  510.  
  511.  
  512.      Functions in FP always have a  single  argument  and  a
  513.  
  514. single  result.  FP functions are analogous to UNIX programs
  515.  
  516. which transform ``standard input'' into ``standard  output''
  517.  
  518. without side effects.
  519.  
  520.  
  521.  
  522.  
  523. February 9, 1987    IFP 0.5 Users Manual                   8
  524.  
  525.  
  526.      The IFP interpreter distinguishs  two  kinds  of  func-
  527.  
  528. tions:   primitive  functions  and  user-defined  functions.
  529.  
  530. Primitive functions  are  built  into  the  FP  interpreter;
  531.  
  532. user-defined  functions  are  created by the user.  The only
  533.  
  534. distinction between the  two  kinds  of  functions  is  that
  535.  
  536. user-defined  functions  have  definitions in terms of other
  537.  
  538. IFP functions.  All  functions  may  be  used  in  the  same
  539.  
  540. manner,  neither  primitive  nor  user-defined functions are
  541.  
  542. privileged in any way.
  543.  
  544.  
  545.      IFP functions are arranged in a tree  structure  analo-
  546.  
  547. gous  to  the way UNIX files are arranged.  Each node of the
  548.  
  549. tree is either a module (directory) or function  (file).   A
  550.  
  551. function  is referenced by its _p_a_t_h_n_a_m_e, which is a sequence
  552.  
  553. of node names separated by slashes.   Pathnames  follow  the
  554.  
  555. UNIX  conventions.  Absolute  pathnames  begin with a slash,
  556.  
  557. which indicates that the path starts at the IFP root  direc-
  558.  
  559. tory  (as specified by the IFProot variable in your environ-
  560.  
  561. ment).  Relative pathnames do not begin with a slash,  which
  562.  
  563. indicates  that  the  path  starts at the current directory.
  564.  
  565. Within function definitions, the current  directory  is  the
  566.  
  567. parent  node of the function.  Pathnames may contain ``..'',
  568.  
  569. which indicates moving up to the parent node.
  570.  
  571.  
  572.      For example, consider the node tree in Figure  1.   The
  573.  
  574. root node is ``r''.  Below are some ways the function  ``b''
  575.  
  576. can  reference  the  other nodes.  Note that the name of the
  577.  
  578. root node is never explicitly used.
  579.  
  580.  
  581.  
  582.  
  583. February 9, 1987    IFP 0.5 Users Manual                   9
  584.  
  585.  
  586.  
  587.                 +-----+
  588.                 |  r  |
  589.                 +-----+
  590.                    /       \
  591.                   /         \
  592.                  /           \
  593.                 /             \
  594.                /               \
  595.               /                 \
  596.              +-----+               +-----+
  597.              | tmp |               | sys |
  598.              +-----+               +-----+
  599.             /   |   \               /   \
  600.            /    |    \             /     \
  601.           /     |     \           /       \
  602.          /      |      \         /         \
  603.          +-----+ +-----+ +-----+  +-----+     +-----+
  604.          | foo | |  a  | |  b  |  | id  |     | sum |
  605.          +-----+ +-----+ +-----+  +-----+     +-----+
  606.           /   \
  607.          /     \
  608.         /       \
  609.     +-----+    +-----+
  610.     |  p  |    |  q  |
  611.     +-----+    +-----+
  612.               Figure 1
  613.  
  614.  
  615.          _________________________
  616.         |_p_a_t_h_n_a_m_e________t_y_p_e______|
  617.         | /sys/sum       absolute|
  618.         | /tmp/foo/p     absolute|
  619.         | foo/p          relative|
  620.         | ../tmp/foo/p   relative|
  621.         | ../sys/sum     relative|
  622.         |_________________________|
  623.  
  624.  
  625.  
  626. _4._2._1.  _P_r_i_m_i_t_i_v_e _F_u_n_c_t_i_o_n_s
  627.  
  628.  
  629.      Primitive functions are built into the IFP interpreter.
  630.  
  631. They  have  pathnames  like  any other function, except that
  632.  
  633. there is no source code file for the function.  The function
  634.  
  635. descriptions  are grouped into sections below.  The pathname
  636.  
  637. for the function's module is in parentheses at  the  top  of
  638.  
  639.  
  640.  
  641.  
  642. February 9, 1987    IFP 0.5 Users Manual                  10
  643.  
  644.  
  645. each section.[7]
  646.  
  647.  
  648.      The following sets (types) are used in the  definitions
  649.  
  650. of functions:
  651.  
  652.  
  653.     A         atoms
  654.     B         boolean values
  655.     O         objects
  656.     R         real numbers
  657.     Z         integers
  658.     S         strings
  659.     T*        sequences with element type T
  660.     T+        non-empty sequences with element type T
  661.     Tn        sequences of length n with element type T
  662.     T[n,m]    sequences of length m with element type Tn
  663.     [T ,T ]   pair of types T  and T
  664.       1  2                   1      2
  665.  
  666. A function returns ``?'' if  the  argument  is  not  in  its
  667.  
  668. domain.   The  notation  x   denotes  the  nth  element of a
  669.               n
  670. sequence X.
  671.  
  672.  
  673.      For example, the domain of  the  addition  function  is
  674.  
  675. [X,Y]  in  [R,R].   That  is  addition  takes a pair of real
  676.  
  677. numbers as its argument.  We could also write this as  [X,Y]
  678.  
  679. in R2, since a pair is a sequence of length two.
  680.  
  681.  
  682.      The types may be pictured neatly with the Venn  diagram
  683.  
  684. in Figure 2:
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692. ____________________
  693.  
  694.    [7] NOTE: The author does not worship  backward  compati-
  695. bility.   Future versions of IFP may put primitive functions
  696. in different subdirectories.
  697.  
  698.  
  699.  
  700.  
  701. February 9, 1987    IFP 0.5 Users Manual                  11
  702.  
  703.  
  704.  
  705.       +----------------------------+
  706.       | O                          |
  707.       |   +--------------------+   |
  708.       |   |  A                 |   |
  709.       |   |    +-----------+   |   |
  710.       |   |    |     B     |   |   |
  711.       |   |    +-----------+   |   |
  712.       |   |    | R         |   |   |
  713.       |   |    |   +---+   |   |   |
  714.       |   |    |   | Z |   |   |   |
  715.       |   |    |   +---+   |   |   |
  716.       |   |    |           |   |   |
  717.       |   |    +-----------+   |   |
  718.       |   |    |     O*    |   |   |
  719.       |   |    +-----------+   |   |
  720.       |   |                    |   |
  721.       |   +--------------------+   |
  722.       |                            |
  723.       | +-+                        |
  724.       | |?|                        |
  725.       | +-+                        |
  726.       |                            |
  727.       +----------------------------+
  728.               Figure 2
  729.  
  730.  
  731. _4._2._1._1.  _S_t_r_u_c_t_u_r_a_l _F_u_n_c_t_i_o_n_s (/_s_y_s)
  732.  
  733.  
  734.      Structural  functions  are  assemble,  reorganize,  and
  735.  
  736. select  data.  The primitive structural functions are listed
  737.  
  738. below:
  739.  
  740.  
  741.  
  742.  
  743. February 9, 1987    IFP 0.5 Users Manual                  12
  744.  
  745.  
  746. __________________________________________________________________________
  747. _|N_a_m_e_______D_o_m_a_i_n_________________D_e_f_i_n_i_t_i_o_n________________________________|
  748. |                                                                        |
  749. |apndl     [X,Y] in [O,On]       <X,y ,y ,...y >                         |
  750. |                                    1  2     n                          |
  751. |apndr     [X,Y] in [Om,O]       <x  x ,...x ,Y>                         |
  752. |                                  1, 2     m                            |
  753. |                nm                                                      |
  754. |cat       X in O                catenate subsequences, e.g.             |
  755. |                                <<a b> <x> <3 5>> -> <a b x 3 5>        |
  756. |                       n                                                |
  757. |distl     [X,Y] in [O,O ]       <<X,y1><X,y2>...<X,yn>>                 |
  758. |                     m                                                  |
  759. |distr     [X,Y] in [O ,O]       <<x1,Y><x2,Y>...<xm,Y>>                 |
  760. |                     n                                                  |
  761. |dropl     [X,K] in [O ,0<_Z<_n]   <xK+1,xK+2,...xn>                       |
  762. |                     n                                                  |
  763. |dropr     [X,K] in [O ,0<_Z<_n]   <x1,x2,...xn-k>                         |
  764. |                                                                        |
  765. |iota      n in Z>_0              <1,2,...n>                              |
  766. |                n                                                       |
  767. |length    X in O                n                                       |
  768. |                     n                                                  |
  769. |pick      [X,K] in [O ,0<Z<_n]   xK                                      |
  770. |                                                                        |
  771. |repeat    [X,K] in [O,0<_Z]      sequence <X,X...X> of length K          |
  772. |                n                                                       |
  773. |reverse   X in O                <xn,xn-1,...x1>                         |
  774. |                     n                                                  |
  775. |takel     [X,K] in [O ,0<_Z<_n]   <x1,x2,...xK>                           |
  776. |                     n                                                  |
  777. |taker     [X,K] in [O ,0<_Z<_n]   <xn-K+1,xn-k+2,...xn>                   |
  778. |                m>0                                                     |
  779. |tl        X in O                <x2,x3,...xm>                           |
  780. |                m>0                                                     |
  781. |tlr       X in O                <x1,x2,...xm-1>                         |
  782. |                [n,m]                                                   |
  783. |trans     X in O                transpose matrix, e.g.                  |
  784. _||________________________________<_<_a__1_>__<_b__2_>__<_c__3_>_>__-_>__<_<_a__b__c_>__<_1__2__3_>_>
  785.  
  786.  
  787.  
  788. _4._2._1._2.  _A_r_i_t_h_m_e_t_i_c (/_m_a_t_h/_a_r_i_t_h)
  789.  
  790.  
  791.      Most IFP arithmetic functions are found here.  Below is
  792.  
  793. a  table  of the existing functions.  Some function's domain
  794.  
  795. may be further restricted due to range limitations.
  796.  
  797.  
  798.  
  799.  
  800. February 9, 1987    IFP 0.5 Users Manual                  13
  801.  
  802.  
  803. _______________________________________________________________
  804. _|N_a_m_e______D_o_m_a_i_n______________D_e_f_i_n_i_t_i_o_n_________________________|
  805. |                                                             |
  806. |+        [X,Y] in [R,R]     X+Y                              |
  807. |                                                             |
  808. |-        ...                X-Y                              |
  809. |                                                             |
  810. |*        ...                XxY                              |
  811. |                                                             |
  812. |%        [X,Y] in [R,R=/0]   X/Y                              |
  813. |                                                             |
  814. |add1     X in R             X+1                              |
  815. |                                                             |
  816. |arcsin   X in R, -1<_X<_1     arcsinX                          |
  817. |                                                             |
  818. |arccos   X in R, -1<_X<_1     arccosX                          |
  819. |                                                             |
  820. |arctan   X in R             arctanX                          |
  821. |                                                             |
  822. |cos      X in R             cosX                             |
  823. |                                                             |
  824. |div      [X,Y] in [R,R=/0]   floor(X/Y)                       |
  825. |                                                             |
  826. |exp      X in R             eX                               |
  827. |                                                             |
  828. |ln       X in R>0           log X                            |
  829. |                               e                             |
  830. |max      [X,Y] in [R,R]     max(X,Y)                         |
  831. |                                                             |
  832. |min      [X,Y] in [R,R]     min(X,Y)                         |
  833. |                                                             |
  834. |minus    X in R             -X                               |
  835. |                                                             |
  836. |mod      [X,Y] in [R,R]     X-Yfloor(X/Y) if Y=/0, 0 otherwise|
  837. |                                                             |
  838. |power    [X,Y] in [R>_0,R]   XY                               |
  839. |                                                             |
  840. |sin      X in R             sinX                             |
  841. |                              _                              |
  842. |sqrt     X in R>0           \|X                              |
  843. |                                                             |
  844. |sub1     X in R             X-1                              |
  845. |                                                             |
  846. |sum      X in R*            X +X +...+X                      |
  847. |                             1  2      n                     |
  848. |tan      X in R             tanX                             |
  849. _|______________________________________________________________|
  850.  
  851.  
  852.  
  853.  
  854. February 9, 1987    IFP 0.5 Users Manual                  14
  855.  
  856.  
  857. _4._2._1._3.  _L_o_g_i_c (/_m_a_t_h/_l_o_g_i_c)
  858.  
  859.  
  860.      Most IFP primitive functions returning  boolean  values
  861.  
  862. are found here.  Below is a table of the existing functions:
  863.  
  864.  
  865.  
  866.  
  867. February 9, 1987    IFP 0.5 Users Manual                  15
  868.  
  869.  
  870.        ______________________________________________
  871.       |_N_a_m_e_______D_o_m_a_i_n__________________D_e_f_i_n_i_t_i_o_n___|
  872.       |                                             |
  873.       | =         [X,Y] in [O,O]         X=Y        |
  874.       |                                             |
  875.       | ~=        ...                    X=/Y        |
  876.       |                                             |
  877.       | <         [X,Y] in [R,R]U[S,S]   X<Y        |
  878.       |                                             |
  879.       | <=        ...                    X<_Y        |
  880.       |                                             |
  881.       | >=        ...                    X>_Y        |
  882.       |                                             |
  883.       | >         ...                    X>Y        |
  884.       |                                             |
  885.       | ~         X in B                 ~X         |
  886.       |                                             |
  887.       | and       [X,Y] in [B,B]         X/\Y       |
  888.       |                                             |
  889.       | all       X in B*                /\x        |
  890.       |                                  k  k       |
  891.       |                                             |
  892.       | any       X in B*                \/xk       |
  893.       |                                  k          |
  894.       | atom      X in O                 X in A     |
  895.       |                                             |
  896.       | boolean   X in O                 X in B     |
  897.       |                                             |
  898.       | false     X in O                 X=#f       |
  899.       |                                             |
  900.       | imply     [X,Y] in [B,B]         ~X\/Y      |
  901.       |                                             |
  902.       | longer    [X,Y] in [Om,On]       m>n        |
  903.       |                                             |
  904.       | member    [X,Y] in [O*,O]        Y in X     |
  905.       |                                             |
  906.       | numeric   X in O                 X in R     |
  907.       |                                             |
  908.       | null      X in O*                X=<>       |
  909.       |                                             |
  910.       | odd       X in Z                 X mod 2 = 1|
  911.       |                                             |
  912.       | or        [X,Y] in [B,B]         X\/Y       |
  913.       |                                             |
  914.       | pair      X in O                 X in [O,O] |
  915.       |                                             |
  916.       | shorter   [X,Y] in [Om,On]       m<n        |
  917.       |                                             |
  918.       | xor       [X,Y] in [B,B]         X=/Y        |
  919.       |______________________________________________|
  920.  
  921.  
  922. String  inequalities  are  defined  from  the  lexigraphical
  923.  
  924.  
  925.  
  926.  
  927. February 9, 1987    IFP 0.5 Users Manual                  16
  928.  
  929.  
  930. (dictionary) ordering.
  931.  
  932.  
  933. _4._2._1._4.  _S_t_r_i_n_g _F_u_n_c_t_i_o_n_s (/_s_y_s)
  934.  
  935.  
  936.      The string functions are:
  937.  
  938.  
  939. ____________________________________________________________
  940. _|N_a_m_e_______D_o_m_a_i_n_____D_e_f_i_n_i_t_i_o_n______________________________|
  941. |                                                          |
  942. |explode   X in S    sequence of characters in X           |
  943. |                                                          |
  944. |implode   X in S*   string made by catenating strings in X|
  945. |                                                          |
  946. |patom     X in A    string representation of X, e.g.      |
  947. |                    123 : patom -> "123"                  |
  948. _|___________________________________________________________|
  949.  
  950.  
  951.  
  952. _4._2._1._5.  _M_i_s_c_e_l_l_a_n_e_o_u_s _F_u_n_c_t_i_o_n_s (/_s_y_s)
  953.  
  954.  
  955.      The miscellaneous functions  are  listed  below.   Each
  956.  
  957. function  description  is  preceded  by  a title line of the
  958.  
  959. form:
  960.  
  961. ____________________________________________________________
  962.  
  963.  
  964. function                   domain                 definition
  965.  
  966.  
  967. ____________________________________________________________
  968.  
  969.  
  970. apply                 [X,F] in [O,S*]           apply F to X
  971.  
  972.  
  973.     F is a sequence of strings representing  a  pathname
  974.     to  a  defined function.  The result is the function
  975.     referenced by F applied to X.  Example:
  976.  
  977.          <<3 4> <math arith "+">> : apply -> 7
  978.  
  979.     F may also be an anonymous  function.   Anonymous  func-
  980.     tions are objects that are enclosed by parentheses.  For
  981.     instance, the previous example could be written as
  982.  
  983.  
  984.  
  985.  
  986. February 9, 1987    IFP 0.5 Users Manual                  17
  987.  
  988.  
  989.             <<3 4> (+)> : apply -> 7
  990.  
  991.     Functions built from functional forms may  also  be  ob-
  992.     jects, for example:
  993.  
  994.     <<<1 2 3> <4 5 6>> (trans|EACH * END|sum) -> 32
  995.  
  996.     Function objects are considered to be atomic.  Functions
  997.     that  act on sequences will not behave properly when ap-
  998.     plied to a function object.  The ``apply'' function com-
  999.     bined with function objects lets us define our own func-
  1000.     tional forms.  For example, we can define  a  functional
  1001.     form Twice which applies a function twice as:
  1002.  
  1003.          DEF Twice AS [apply,2]|apply;
  1004.  
  1005.     Then we can write:
  1006.  
  1007.           3 : [id,([id,id]|*)] | Twice -> 81
  1008.  
  1009.     ________________________________________________________
  1010.  
  1011. assoc               [X,Y] in [(O+)*,O]    associative lookup
  1012.  
  1013.  
  1014.     X is an association sequence,  which  is  a  se-
  1015.     quence  of  non-empty  subsequences.   The first
  1016.     element of each subsequence is the  _k_e_y  of  the
  1017.     subsequence.   The  result of assoc is the first
  1018.     subsequence of X with a key equal to Y.   If  no
  1019.     matching  key  is found, f is returned.  The key
  1020.     may be any type of object.  Examples:
  1021.  
  1022.          <<<a b c> <w x y z> <i j>> w> -> <w x y z>
  1023.          <<<a b c> <w x y z> <i j>> U> -> f
  1024.  
  1025.  
  1026.     ____________________________________________________
  1027.  
  1028. def                       X in S+                 definition
  1029.  
  1030.  
  1031.         The definition function returns  the  object
  1032.         representation   of   its   argument.    The
  1033.         representation of a function is  a  sequence
  1034.         of  strings  denoting its absolute pathname.
  1035.         The representation of a functional form is a
  1036.         sequence.  The first element of the sequence
  1037.         is a pathname to the functional  form.   The
  1038.         remaining   elements  of  the  sequence  are
  1039.         parameters of the functional form.  Suppose,
  1040.         for  example,  we  define  the inner product
  1041.         function:
  1042.  
  1043.  
  1044.  
  1045.  
  1046. February 9, 1987    IFP 0.5 Users Manual                  18
  1047.  
  1048.  
  1049.          DEF Inner AS trans | EACH * END | INSERT + END
  1050.  
  1051.         and ``Inner'' is  defined  with  a  module  with
  1052.         pathname  ``/math/linear''.  Then ``<math linear
  1053.         Inner> : def'' will result in:
  1054.  
  1055.           <
  1056.                <sys compose>
  1057.                <sys trans>
  1058.                <<sys each> <math arith *>>
  1059.                <<sys insertr> <math arith +>>
  1060.           >
  1061.  
  1062.         Currently,  the  representations  of  functional
  1063.         forms are:
  1064.  
  1065.     ________________________________________________________
  1066.        | #c                       <<sys constant> #c>          |
  1067.        | #?                       <<sys constant>>             |
  1068.        | n                        <<sys select> n>             |
  1069.        | nr                       <<sys select> -n>            |
  1070.        | f1|f2|...fn              <<sys compose>, f1,f2,...fn  |
  1071.        | [f1,f2,...fn]            <<sys construct>, f1,f2,...fn|
  1072.        | ^c                       <<sys fetch> c>              |
  1073.        | EACH f END               <<sys each> f>               |
  1074.        | FILTER p END             <<sys filter> p>             |
  1075.        | INSERT f END             <<sys insertr> f>            |
  1076.        | IF p THEN g ELSE h END   <<sys if> p g h>             |
  1077.        ||_W_H_I_L_E__p__D_O__f__E_N_D__________<_<_s_y_s__w_h_i_l_e_>__p__f_>______________||
  1078.  
  1079.         ELSIF   clauses   are   always   expanded   into
  1080.         equivalent  nested  IF-THEN-ELSE  constructions.
  1081.         Note the special case for #?, the representation
  1082.         <<sys  constant>  ?> would be useless due to the
  1083.         bottom-preserving property.
  1084.  
  1085.         ________________________________________________
  1086.  
  1087. id                        X in O                    identity
  1088.  
  1089.  
  1090.         The identity function returns its  argu-
  1091.         ment.  It is useful as a place holder in
  1092.         functional  forms.   For  example,   the
  1093.         ``square'' function can be written as:
  1094.         DEF Square AS [id,id] | *;
  1095.  
  1096.  
  1097.  
  1098.  
  1099. February 9, 1987    IFP 0.5 Users Manual                  19
  1100.  
  1101.  
  1102. _4._2._2.  _U_s_e_r _D_e_f_i_n_e_d _F_u_n_c_t_i_o_n_s
  1103.  
  1104.  
  1105.      The user may define functions by  creating  defini-
  1106.  
  1107. tion files (source code).  The definition in the file is
  1108.  
  1109. of the form:
  1110.  
  1111.             DEF _f_o_o AS _b_a_r;
  1112.  
  1113. where _f_o_o is the name of the function and _b_a_r is the de-
  1114.  
  1115. finition.   The  name of the file must also be _f_o_o.  The
  1116.  
  1117. definition may be any IFP function.   For  example,  you
  1118.  
  1119. can define the square function as:
  1120.  
  1121.     DEF Square AS [/sys/id,/sys/id] | /math/arith/*;
  1122.  
  1123.  
  1124.      Writing out the entire pathname of functions is not
  1125.  
  1126. necessary.   If the function is defined in the same sub-
  1127.  
  1128. directory, then just its  name  is  necessary.   If  the
  1129.  
  1130. function  is  defined  in another subdirectory, then you
  1131.  
  1132. can ``import'' it.  An imported function can  be  refer-
  1133.  
  1134. enced  as  though  it were defined in the directory into
  1135.  
  1136. which it is imported.  To import functions into  a  sub-
  1137.  
  1138. directory,  you  create an ``import file'' with the name
  1139.  
  1140. %IMPORT with the editor.  The form of the  %IMPORT  file
  1141.  
  1142. is:
  1143.  
  1144.      FROM directory  IMPORT f ,f , ... f ;
  1145.      FROM directory1 IMPORT g1,g2, ... gn;
  1146.           ...      2         1  2       m
  1147.  
  1148. The directory is a pathname to a directory.   For  exam-
  1149.  
  1150. ple, typical import file might be:
  1151.  
  1152.  
  1153.     FROM /sys IMPORT apndr,distl,id,iota,takel;
  1154.  
  1155.  
  1156.  
  1157.  
  1158. February 9, 1987    IFP 0.5 Users Manual                  20
  1159.  
  1160.  
  1161.     FROM /math/arith IMPORT +,-,*,%;
  1162.  
  1163. Since the function ``id'' is imported, the  square  function
  1164. can be defined as:
  1165.          DEF Square AS [id,id] | *;
  1166.  
  1167.  
  1168. _4._2._3.  _F_u_n_c_t_i_o_n_a_l _V_a_r_i_a_b_l_e_s
  1169.  
  1170.  
  1171.      Functional variables [Bac81a] are locally defined func-
  1172.  
  1173. tions with special scope rules. A functional variable defin-
  1174.  
  1175. ition is written:
  1176.  
  1177.              {_l_h_s := _f_u_n_c_t_i_o_n}
  1178.  
  1179. where _l_h_s (left hand side) is either a function name or con-
  1180.  
  1181. struction  of  _l_h_s's.   All function names in the _l_h_s become
  1182.  
  1183. functional variables within their scope.  The scope is _b_o_u_n_-
  1184.  
  1185. _d_a_r_y  _s_t_r_u_c_t_u_r_e_d as opposed to block structured, which means
  1186.  
  1187. that the variables may be seen only  through  certain  boun-
  1188.  
  1189. daries.   The  scope  rules  can be defined by the following
  1190.  
  1191. transformations:
  1192.  
  1193.  {V := h} v -> h | V -1
  1194.             v
  1195.  {V := h} [f ,f ,...] -> [{V := h} f , {V := h} f , ...]
  1196.         1  2                    1            2
  1197.  {V := h} IF p THEN x       IF {V := h} p THEN {V := h} x
  1198.       ELSE y        ->   ELSE {V := h} y
  1199.       END               END
  1200.  
  1201. where -> indicates that the left side may be  simplified  to
  1202.  
  1203. the  right  side.  ``V'' denotes a left-hand side containing
  1204.  
  1205. the functional variable ``v''.  V -1 is the inversion  func-
  1206.                  v
  1207. tion  of ``V'' for ``v''.  For example, if V = [a,b,c], then
  1208.  
  1209. V -1 = 3. Variables must be defined before use.   Note  that
  1210.  c
  1211. the vertical bar of composition cuts off the scope, e.g. in
  1212.  
  1213.             {[_x,_y] := id} _g | _h
  1214.  
  1215.  
  1216.  
  1217.  
  1218. February 9, 1987    IFP 0.5 Users Manual                  21
  1219.  
  1220.  
  1221. the function _g can ``see'' _x and _y, but _h can not.
  1222.  
  1223.  
  1224.      An example of a definition  with  functional  variables
  1225.  
  1226. appears below:
  1227.  
  1228. (*
  1229.  * InsertSort
  1230.  *
  1231.  * This function sorts a sequence of numbers or strings into ascending order
  1232.  * using insertion sort.
  1233.  *
  1234.  * Examples:
  1235.  *
  1236.  *      <3 1 4 1 5 9 2> : InsertSort == <1 1 2 3 4 5 9>
  1237.  *
  1238.  *      <all work and no play> : InsertSort == <all and no play work>
  1239.  *
  1240.  * The sequence may not mix strings and numbers.
  1241.  *)
  1242. DEF InsertSort AS
  1243.    IF null THEN id     (* Check for trivial case *)
  1244.    ELSE
  1245.       [tl,[1]] | apndr |
  1246.       INSERT
  1247.      {[Element,Seq] := id}
  1248.      {[Left,Right] := [Seq, distl | FILTER > END | length] | [takel,dropl]}
  1249.      [Left,[Element],Right] | cat
  1250.       END
  1251.    END;
  1252.  
  1253. In this example, _E_l_e_m_e_n_t, _S_e_q, _L_e_f_t, and _R_i_g_h_t are function-
  1254.  
  1255. al variables.
  1256.  
  1257.  
  1258.  
  1259. _4._3.  _F_u_n_c_t_i_o_n_a_l _F_o_r_m_s
  1260.  
  1261.  
  1262.      Functional  forms  combine  functions  and  objects  to
  1263.  
  1264. create new functions.
  1265.  
  1266.  
  1267. _4._3._1.  _C_o_n_s_t_a_n_t
  1268.  
  1269.  
  1270.      Constant functions always return the same  result  when
  1271.  
  1272. applied to any value which is not ``?''.  Constant functions
  1273.  
  1274.  
  1275.  
  1276.  
  1277. February 9, 1987    IFP 0.5 Users Manual                  22
  1278.  
  1279.  
  1280. are written as:
  1281.  
  1282.                  #_c
  1283.  
  1284. where c is the constant value to  be  returned.  A  constant
  1285.  
  1286. function  applied  to ``?'' results in ``?''.  Note that the
  1287.  
  1288. function ``#?'' always returns `?'.  Examples:
  1289.  
  1290.         923 : #<cat in hat> -> <cat in hat>
  1291.         <a b c d e f> : #427 -> 427
  1292.         ? : #<q w er t y> -> ?
  1293.         5 : #? -> ?
  1294.  
  1295.  
  1296. _4._3._2.  _S_e_l_e_c_t_i_o_n
  1297.  
  1298.  
  1299.      Selector functions return the nth element of a sequence
  1300.  
  1301. and  are  written as n, where n is a positive integer.  Note
  1302.  
  1303. the distinction between #5, which returns the value  5,  and
  1304.  
  1305. 5,  which  returns  the fifth element of its argument. There
  1306.  
  1307. are also a corresponding set of select-from-right functions,
  1308.  
  1309. written  as  nr. These select the nth element of a sequence,
  1310.  
  1311. counting from the right. All selectors return ``?''  if  the
  1312.  
  1313. argument has no nth element or is not a sequence.  Below are
  1314.  
  1315. some examples of applying selector functions:
  1316.  
  1317.         <a b c d e> : 1 -> a
  1318.         <a b c d e> : 2 -> b
  1319.         <apple banana cherry> : 1r -> cherry
  1320.         <apple banana cherry> : 4 -> ?
  1321.         hello : 1 -> ?
  1322.  
  1323.  
  1324. _4._3._3.  _C_o_m_p_o_s_i_t_i_o_n
  1325.  
  1326.  
  1327.      The function composition of two  functions  is  written
  1328.  
  1329. as:
  1330.  
  1331.  
  1332.  
  1333.  
  1334. February 9, 1987    IFP 0.5 Users Manual                  23
  1335.  
  1336.  
  1337.                f | g
  1338.  
  1339. Applying the result function is the same as applying  f  and
  1340.  
  1341. then g.  E.g.: Function composition is defined by the equal-
  1342.  
  1343. ity:
  1344.  
  1345.  
  1346.          x : (f | g) =_ (x : f) : g
  1347.  
  1348. Since function composition is associative,  the  composition
  1349.  
  1350. of  more  than  two  functions does not require parentheses.
  1351.  
  1352. The composition of f ,f ,...f  is written:
  1353.             1  2     n
  1354.  
  1355.               f  | f  | ...f
  1356.                1    2       n
  1357. Composition syntax is identical to UNIX's pipe notation  for
  1358.  
  1359. a  reason:  function  composition  is  isomorphic  to a pipe
  1360.  
  1361. between processes without side effects.
  1362.  
  1363.  
  1364. _4._3._4.  _C_o_n_s_t_r_u_c_t_i_o_n
  1365.  
  1366.  
  1367.      The construction of functions is written  as  bracketed
  1368.  
  1369. list  of  the  functions.   For example, the construction of
  1370.  
  1371. functions f  is written:
  1372.        i
  1373.  
  1374.                [f ,f ,...f ]
  1375.              1  2     n
  1376. Function construction is defined by the equality:
  1377.  
  1378.  
  1379.       x : [f ,f ,...f ] =_ <x:f ,x:f ,...x:f >
  1380.         1  2     n        1    2       n
  1381.  
  1382. _4._3._5.  _A_p_p_l_y _t_o _E_a_c_h
  1383.  
  1384.  
  1385.      The EACH functional form applies  a  function  to  each
  1386.  
  1387. element of a sequence.  It is written as
  1388.  
  1389.              EACH _f END
  1390.  
  1391.  
  1392.  
  1393.  
  1394. February 9, 1987    IFP 0.5 Users Manual                  24
  1395.  
  1396.  
  1397. It is defined by the equality:
  1398.  
  1399.       <x ,x ,...x > : EACH f END =_ <x :f,x :f,...x :f>
  1400.     1  2     n                   1    2       n
  1401.  
  1402. _4._3._6.  _I_f-_T_h_e_n-_E_l_s_e
  1403.  
  1404.  
  1405.      The IF functional form allows conditional function  ap-
  1406.  
  1407. plication.  It is written as
  1408.  
  1409.            IF _p THEN _g ELSE _h END
  1410.  
  1411. and is defined by the equality:
  1412.  
  1413.  
  1414.                      | g(x) if p(x)=t
  1415.                      |
  1416.        x :IF p THEN g ELSE h END  -> | h(x) if p(x)=f
  1417.                      | ?    otherwise
  1418.                      |
  1419. The level of nesting of conditional forms may be reduced  by
  1420.  
  1421. using ELSIF clauses:
  1422.  
  1423.             IF p  THEN g
  1424.             ELSE1       1
  1425.                IF p  THEN g
  1426.                ELSE2       2
  1427.               IF p  THEN g
  1428.               ELSE3h      3
  1429.               END
  1430.                END
  1431.             END
  1432.  
  1433.  
  1434. _4._3._7.  _F_i_l_t_e_r
  1435.  
  1436.  
  1437.      The FILTER functional form filters through elements  of
  1438.  
  1439. a sequence satisfying a predicate.  It is written as:
  1440.  
  1441.             FILTER _p END
  1442.  
  1443. where p is the predicate.  It is defined by  the  functional
  1444.  
  1445. equality:
  1446.  
  1447.            EACH
  1448.           IF _p THEN [id] ELSE [] END
  1449.            END | cat
  1450.  
  1451.  
  1452.  
  1453.  
  1454. February 9, 1987    IFP 0.5 Users Manual                  25
  1455.  
  1456.  
  1457. For example, if you wish to find all numeric elements  in  a
  1458.  
  1459. sequence, you could write:
  1460.  
  1461.              FILTER numeric END
  1462.  
  1463. The FILTER functional form is an IFP  extension  to  Backus'
  1464.  
  1465. FP.
  1466.  
  1467.  
  1468. _4._3._8.  _R_i_g_h_t _I_n_s_e_r_t
  1469.  
  1470.  
  1471.      The INSERT functional form is defined by the recursion:
  1472.  
  1473. INSERT _f END =_ IF tl|null THEN 1 ELSE [1,tl | INSERT _f END] | _f END
  1474.  
  1475. Typically it is used for crunching a sequence down.  For ex-
  1476.  
  1477. ample,
  1478.  
  1479.             INSERT + END
  1480.  
  1481. returns the sum of a sequence.
  1482.  
  1483.  
  1484.      Unlike Backus' FP, functions formed with INSERT are al-
  1485.  
  1486. ways  undefined  for empty sequences.  The reason is that it
  1487.  
  1488. is impractical for the interpreter to know the identity ele-
  1489.  
  1490. ment  of  user-defined functions.  The number of cases where
  1491.  
  1492. the interpreter could know the identity element are  so  few
  1493.  
  1494. that  you  might  as well define special functions for those
  1495.  
  1496. cases, e.g:
  1497.  
  1498.      DEF sum AS IF null THEN #0 ELSE INSERT + END END;
  1499.  
  1500. Alternatively, you can append the identity  element  to  the
  1501.  
  1502. end of the sequence before inserting, e.g.:
  1503.  
  1504.      DEF sum AS [id,#0] | apndr | INSERT + END;
  1505.  
  1506.  
  1507.      Currently there is no ``left insert'' form.   The  left
  1508.  
  1509. insertion of f can be written as:
  1510.  
  1511.  
  1512.  
  1513.  
  1514. February 9, 1987    IFP 0.5 Users Manual                  26
  1515.  
  1516.  
  1517.            reverse | INSERT reverse|f END
  1518.  
  1519.  
  1520. _4._3._9.  _W_h_i_l_e
  1521.  
  1522.  
  1523.      The WHILE functional form  allows  indefinite  composi-
  1524.  
  1525. tion. It is written as:
  1526.  
  1527.              WHILE _p DO _f END;
  1528.  
  1529. and is defined by the recursive functional equality:
  1530.  
  1531.      WHILE _p DO _f END =_ IF _p THEN
  1532.                    _f | WHILE _p DO _f END
  1533.                  ELSE id
  1534.                  END
  1535.  
  1536. That is the _W_H_I_L_E PFO  applies  the  fewest  f's  such  that
  1537.  
  1538. _x:_f:_f:_f...:_p is true.
  1539.  
  1540.  
  1541. _4._3._1_0.  _F_e_t_c_h[_8]
  1542.  
  1543.  
  1544.      The fetch functional form allows easy access to associ-
  1545.  
  1546. ation  sequences (see function /sys/assoc in section 4.2.1.5
  1547.  
  1548. for a description of association  sequences.)   A  fetch  is
  1549.  
  1550. written  as ^c, where c is an object.  The fetch form is de-
  1551.  
  1552. fined by the functional equality:
  1553.  
  1554.      ^_c =_= IF EACH pair END | all THEN [id,#_c]|assoc|2
  1555.       ELSE #?
  1556.       END;
  1557.  
  1558. Note that the input is restricted to a  sequence  of  pairs.
  1559.  
  1560. For example,
  1561.  
  1562.            <<a 1> <b 2> <c 3>> : ^b -> 2
  1563.  
  1564.  
  1565. ____________________
  1566.  
  1567.    [8]The fetch functional form is being  deimplemented.  It
  1568. may or may not exist on your IFP interpreter.
  1569.  
  1570.  
  1571.  
  1572.  
  1573. February 9, 1987    IFP 0.5 Users Manual                  27
  1574.  
  1575.  
  1576. _4._4.  _C_o_m_m_e_n_t_s
  1577.  
  1578.  
  1579.      Comments are delimited by matching pairs of ``(*''  and
  1580.  
  1581. ``*)''.  Comments may be inserted anywhere not adjacent to a
  1582.  
  1583. token.  For example:
  1584.  
  1585. DEF foo AS bar; (* This is a comment.  DEF foo AS bar is not a comment *)
  1586.  
  1587.  
  1588. _4._5.  _S_y_n_t_a_x _S_u_m_m_a_r_y
  1589.  
  1590.  
  1591.      Below is an EBNF grammar for IFP:
  1592.  
  1593.  
  1594. ________________________________________________________________________________________
  1595. |Def ->            'DEF String 'AS' Comp ';'                                           |
  1596. |Comp ->            Simple { '|' Simple }                                              |
  1597. |Simple ->          Conditional | Constant | Construction | Each | Filter |            |
  1598. |                  Insert | Path | While | Fetch | Debug | FunVar                      |
  1599. |Conditional ->    'IF' Comp 'THEN' Comp { 'ELSIF' Comp 'THEN' Comp } 'ELSE' Comp 'END'|
  1600. |While ->          'WHILE' Comp 'DO' Comp 'end'                                        |
  1601. |Insert ->         'INSERT' Comp 'END'                                                 |
  1602. |Each ->           'EACH' Comp 'END'                                                   |
  1603. |Filter ->         'FILTER' Comp 'END'                                                 |
  1604. |Fetch ->          '^' String                                                          |
  1605. |Constant ->       '#' Object                                                          |
  1606. |Debug ->          '@' Object                                                          |
  1607. |FunVar ->         '{' Lhs ':=' Comp '}'                                               |
  1608. |Lhs ->            String | '[' [ Lhs { ',' Lhs } ] ']'                                |
  1609. |Construction ->   '[' [Comp {',' Comp}] ']'                                           |
  1610. |Path ->           ['/'] String {'/' String}                                           |
  1611. |Object ->         Bottom | Atom | '<' [Atom {','Atom}] '>'                            |
  1612. |Bottom ->         '?'                                                                 |
  1613. |Atom ->           Number | String | Boolean                                           |
  1614. _||B_o_o_l_e_a_n__-_>_________'_t_'__|__'_f_'_____________________________________________________________||
  1615.  
  1616. Strings may be in single  or  double  quotes.   The  strings
  1617. ``t''  and  ``f''  must  be  quoted to distinguish them from
  1618. boolean atoms.  Strings of digits must  also  be  quoted  to
  1619. distinguish them from numeric atoms.
  1620.  
  1621.  
  1622. _5.  _I_F_P _G_r_a_p_h_i_c_s (_o_p_t_i_o_n_a_l)[_9]
  1623. ____________________
  1624.  
  1625.    [9]This option is currently  not  implemented.   If  this
  1626. section  inspires  you,  get the source code and fix it (see
  1627. G_*.c).
  1628.  
  1629.  
  1630.  
  1631.  
  1632. February 9, 1987    IFP 0.5 Users Manual                  28
  1633.  
  1634.  
  1635.      There are no graphics primitives in IFP itself,  rather
  1636.  
  1637. IFP  is  used  to  calculate a display list.  A display-list
  1638.  
  1639. processor then draws the picture specified  by  the  display
  1640.  
  1641. list.   To  send an IFP result to the display-list processor
  1642.  
  1643. instead of the screen, use the command:
  1644.  
  1645.           graph object : function
  1646.  
  1647. instead of the ``show'' command.
  1648.  
  1649.  
  1650. _5._1.  _C_o_o_r_d_i_n_a_t_e _S_y_s_t_e_m
  1651.  
  1652.  
  1653.      Points on the graphics display are referenced by  <X,Y>
  1654.  
  1655. coordinate  pairs.  <0,0> is the lower left corner, <1,1> is
  1656.  
  1657. the upper left corner.   Currently  there  is  no  clipping.
  1658.  
  1659. Lines  outside the display are wrap around in weird and not-
  1660.  
  1661. so-wonderful ways.
  1662.  
  1663.  
  1664. _5._2.  _D_i_s_p_l_a_y _L_i_s_t _S_t_r_u_c_t_u_r_e
  1665.  
  1666.  
  1667.      Below is an EBNF grammar for the display list.
  1668.  
  1669.  
  1670. ______________________________________________________________________________
  1671. |                                                                            |
  1672. | display-list ->   < {display-list} > | polyline | color | transform | text |
  1673. | polyline ->       <'line' { < x y > } >                                    |
  1674. | color ->          <'color' color-index display-list >                      |
  1675. | text ->           <'text' atom size ['center']>                            |
  1676. | transform ->      <'trans' t-matrix display-list >                         |
  1677. | t-matrix ->       <<Txx Txy Tx0> <Tyx Tyy Ty0>>                            |
  1678. _||_____________________________________________________________________________||
  1679.  
  1680.  
  1681. _5._2._1.  _P_o_l_y_l_i_n_e
  1682.  
  1683.  
  1684.      The polyline structure specifies a sequence of  points.
  1685.  
  1686. It is of the form:
  1687.  
  1688.  
  1689.  
  1690.  
  1691. February 9, 1987    IFP 0.5 Users Manual                  29
  1692.  
  1693.  
  1694.          <line <x ,y > <x ,y > ... <x ,y >>
  1695.              1  1    2  2        n  n
  1696. where each <x ,y > is a point coordinate.   Adjacent  points
  1697.          i  i
  1698. in  the sequence are connected with line segments. For exam-
  1699.  
  1700. ple, the sequence:
  1701.  
  1702.         <line <0 0> <0 5> <1 5> <1 0> <0 0>>
  1703.  
  1704. draws a box 1 unit wide and 5 units high.
  1705.  
  1706.  
  1707. _5._2._2.  _C_o_l_o_r
  1708.  
  1709.  
  1710.      The color structure draws the display-list in the color
  1711.  
  1712. specified  by the color index (0..15).  The color applies to
  1713.  
  1714. all parts of the  subordinate  display-list  which  are  not
  1715.  
  1716. subordinate  to a color structure within.  In other words, a
  1717.  
  1718. structure is colored by its  inner-most  bounding  ``color''
  1719.  
  1720. structure.
  1721.  
  1722.  
  1723. _5._2._3.  _T_r_a_n_s_f_o_r_m
  1724.  
  1725.  
  1726.      The  transform  structure  draws  the  display-list  as
  1727.  
  1728. transformed  by  the  t-matrix.   Transforms  may be nested.
  1729.  
  1730. Transforming a display-list converts coordinates <x,y>  into
  1731.  
  1732. coordinates <x',y'> via the formula:
  1733.  
  1734.  
  1735.         | x' |     | Txx  Txy  Tx0 |  | x |
  1736.         |    |  =  |               |  | y |
  1737.         | y' |     | Tyx  Tyy  Ty0 |  |   |
  1738.                |               |  | 1 |
  1739.  
  1740. _5._2._4.  _T_e_x_t
  1741.  
  1742.  
  1743.      The text structure draws the atom with  the  lower-left
  1744.  
  1745. corner  at (0,0).  Each character is drawn in a _s_i_z_e by _s_i_z_e
  1746.  
  1747.  
  1748.  
  1749.  
  1750. February 9, 1987    IFP 0.5 Users Manual                  30
  1751.  
  1752.  
  1753. box (including spacing) The lower-left corner of the text is
  1754.  
  1755. at  <0  0>  by default.  Including the _c_e_n_t_e_r option centers
  1756.  
  1757. the text on <0 0>.
  1758.  
  1759.  
  1760.  
  1761. _6.  _D_e_b_u_g_g_i_n_g
  1762.  
  1763.  
  1764.      Currently, IFP has simple program trace  mechanism.[10]
  1765.  
  1766. To trace a function, respond to the IFP prompt with:
  1767.  
  1768.            trace on f ,f ,...f ;
  1769.                  1  2     n
  1770. where the f's are functions to be traced.  Whenever a traced
  1771.  
  1772. function  is  invoked,  its  argument  and result are shown.
  1773.  
  1774. Also, the argument and result of all  called  functions  are
  1775.  
  1776. shown.  To stop tracing functions, respond to the IFP prompt
  1777.  
  1778. with:
  1779.  
  1780.           trace off f ,f ,...f ;
  1781.                  1  2     n
  1782.  
  1783.      When tracing, the interpreter ellipses are used to  ab-
  1784.  
  1785. breviate functions.  You can set the depth at which ellipses
  1786.  
  1787. occur with the _d_e_p_t_h command:
  1788.  
  1789.               depth n
  1790.  
  1791. where n is a non-negative integer.   The  default  depth  is
  1792.  
  1793. two.
  1794.  
  1795.  
  1796.      There is also a  functional  form  for  creating  trace
  1797.  
  1798. functions.  Its form is
  1799.  
  1800.               @_m_e_s_s_a_g_e
  1801. ____________________
  1802.  
  1803.    [10]This will be replaced by a much better trace  mechan-
  1804. ism as soon as the author as time to design one.
  1805.  
  1806.  
  1807.  
  1808.  
  1809. February 9, 1987    IFP 0.5 Users Manual                  31
  1810.  
  1811.  
  1812. The function formed always returns its  argument  unchanged,
  1813.  
  1814. and  it  prints ``message: '' followed by its argument.  For
  1815.  
  1816. example,
  1817.  
  1818.          <1 3 5> : EACH @banana END
  1819.  
  1820. will print the messages:
  1821.  
  1822.              banana: 1
  1823.              banana: 3
  1824.              banana: 5
  1825.  
  1826. This tracing functional form is for debugging only, since it
  1827.  
  1828. creates  a side effect (the message!), it is not truly func-
  1829.  
  1830. tional.
  1831.  
  1832.  
  1833.  
  1834. _7.  _D_i_f_f_e_r_e_n_c_e_s _b_e_t_w_e_e_n _I_F_P _a_n_d _B_a_c_k_u_s' _F_P
  1835.  
  1836.  
  1837. _7._1.  _D_o_m_a_i_n
  1838.  
  1839.  
  1840.      Backus' FP has two types of atom, the string and  empty
  1841.  
  1842. sequence.  IFP atoms do not include the empty sequence.  IFP
  1843.  
  1844. include numbers and truth  values  as  atoms  distinct  from
  1845.  
  1846. strings.
  1847.  
  1848.  
  1849. _7._2.  _F_u_n_c_t_i_o_n_s
  1850.  
  1851.  
  1852.      There are many new  primitives.   See  the  section  on
  1853.  
  1854. ``Primitives''  elsewhere.   Of  particular interest are the
  1855.  
  1856. functions _c_a_t, _d_r_o_p_l, _t_a_k_e_l, _t_a_k_e_r, and _i_o_t_a.
  1857.  
  1858.  
  1859. _7._3.  _F_u_n_c_t_i_o_n_a_l _F_o_r_m_s
  1860.  
  1861.  
  1862.      Backus' FP defines the INSERT form for empty  sequences
  1863.  
  1864. as  returning u , the right identity element of f.  IFP does
  1865.            f
  1866.  
  1867.  
  1868.  
  1869.  
  1870. February 9, 1987    IFP 0.5 Users Manual                  32
  1871.  
  1872.  
  1873. not define INSERT for empty sequences.   If  necessary,  use
  1874.  
  1875. one of the following functions:
  1876.  
  1877.        IF null THEN u  ELSE INSERT f END END
  1878.              f
  1879.        [id,u ] | apndr | INSERT f END
  1880.         f
  1881.  
  1882.      IFP has a new functional form, FILTER, which filters  a
  1883.  
  1884. sequence according to a predicate.  It is written as:
  1885.  
  1886.             FILTER p END
  1887.  
  1888. When applied to a sequence X, it returns a  sequence  of  x
  1889.                                i
  1890. for which p is true.
  1891.  
  1892.  
  1893. _7._4.  _S_y_n_t_a_x
  1894.  
  1895.  
  1896.      The IFP syntax is designed  to  facilitate  indentation
  1897.  
  1898. and  comments.   All  functional forms bracket their parame-
  1899.  
  1900. ters, so no  parentheses  are  necessary.   The  differences
  1901.  
  1902. between Backus' FP and IFP syntax are shown below.
  1903.  
  1904.  
  1905.     ___________________________________________________
  1906.    |_B_a_c_k_u_s___________I_F_P________________________________|
  1907.    | CBA             A | B | C                        |
  1908.    | [F,G,H]         [F,G,H]                          |
  1909.    | p->f;g          IF p THEN f ELSE g END           |
  1910.    | p->f; q->g; h   IF p THEN f ELSIF q THEN g ELSE h|
  1911.    | Af              EACH f END                       |
  1912.    | /f              INSERT f END                     |
  1913.    | (while p f)     WHILE p DO f END                 |
  1914.    | (_bu f x)        [id,#x] | _f                      |
  1915.    | f               #_f                               |
  1916.    | Def f =_ x       DEF f AS x;                      |
  1917.    | U               <>                               |
  1918.    | _|               ?                                |
  1919.    |___________________________________________________|
  1920.  
  1921. Also, parentheses are neither necessary nor allowed  in  IFP
  1922.  
  1923. function definitions.
  1924.  
  1925.  
  1926.  
  1927.  
  1928. February 9, 1987    IFP 0.5 Users Manual                  33
  1929.  
  1930.  
  1931.      Finally, IFP functions are arranged in a tree structure
  1932.  
  1933. and  referenced  by  pathnames.   All pathnames are expanded
  1934.  
  1935. into absolute pathnames when read by the interpreter, so the
  1936.  
  1937. meaning  of  a  pathname  is  static.   This is an important
  1938.  
  1939. point, otherwise IFP would have significantly different (and
  1940.  
  1941. more complex) semantics than Backus' FP.
  1942.  
  1943.  
  1944. _8.  _F_u_n_c_t_i_o_n_a_l _P_r_o_g_r_a_m_m_i_n_g _T_e_c_h_n_i_q_u_e_s
  1945.  
  1946.  
  1947. _8._1.  _F_u_n_c_t_i_o_n_a_l _P_r_o_g_r_a_m_m_i_n_g _I_d_e_n_t_i_t_i_e_s
  1948.  
  1949.  
  1950.      Functional programs can be improved by  algebraic  sub-
  1951.  
  1952. stitutions.   Below  is a table of some IFP identities.  The
  1953.  
  1954. notation ``f=_g'' indicates f and g are equal  and  have  the
  1955.  
  1956. same  domain.   The  notation  ``f < g'' indicates that g is
  1957.  
  1958. equal to f over f's domain, but may  have  a  larger  domain
  1959.  
  1960. than f.
  1961.  
  1962.  
  1963.  __________________________________________________________
  1964. | EACH f END | EACH g END   =_     EACH f | g END          |
  1965. | [#c,id] | distl           =_     EACH [#c,id] END        |
  1966. | [takel,dropl] | cat        <    1                       |
  1967. | apndl | length             <    2 | length | add1       |
  1968. | apndr | length             <    1 | length | add1       |
  1969. | iota | length              <    id                      |
  1970. | reverse | length          =_     length                  |
  1971. | tl | length                <    length | sub1           |
  1972. | tlr | length               <    length | sub1           |
  1973. | apndl | reverse           =_     [2 | reverse,1] | apndr |
  1974. | apndr | reverse           =_     [2,1 | reverse] | apndl |
  1975. | reverse | reverse          <    id                      |
  1976. ||_t_r_a_n_s__|__t_r_a_n_s_______________<_____i_d________________________||
  1977.  
  1978.  
  1979.  
  1980.  
  1981. February 9, 1987    IFP 0.5 Users Manual                  34
  1982.  
  1983.  
  1984. _8._2.  _C_o_m_m_o_n _S_u_b_f_u_n_c_t_i_o_n_s
  1985.  
  1986.  
  1987.      The interpreter is not very smart about common subfunc-
  1988.  
  1989. tions, it reevaluates a function every time its encountered.
  1990.  
  1991. You can always factor out such common subfunctions by creat-
  1992.  
  1993. ing extra function constructions.  Consider the function:
  1994.  
  1995.  
  1996.             [f,a,f|g,b]
  1997.  
  1998. You can move f to outside the construction  by  forming  the
  1999.  
  2000. pair [id,f] and making the transformation:
  2001.  
  2002.  
  2003.       [f, a, f|g, b]  ->  [id,f] | [2, 1|a, 2|g, 1|b]
  2004.  
  2005. In general, create the pair [id,f].  Then replace all  lead-
  2006.  
  2007. ing  occurrences  of f in the construction by the 2 selector
  2008.  
  2009. and insert a leading 1 selector elsewhere in  the  construc-
  2010.  
  2011. tion.
  2012.  
  2013.  
  2014. _8._3.  _S_t_a_t_e _M_a_c_h_i_n_e_s
  2015.  
  2016.  
  2017.      You can simulate a state machine in IFP by defining the
  2018.  
  2019. state  transition  function D, which maps an input and state
  2020.  
  2021. into another state:
  2022.  
  2023.          [input,state] : _D -> state
  2024.  
  2025. You then run the state machine with the function
  2026.  
  2027.            apndl | reverse | INSERT _D END
  2028.  
  2029. which yields the final state when  applied  to  the  initial
  2030.  
  2031. conditions <initial-state,tape>.
  2032.  
  2033.  
  2034.  
  2035.  
  2036. February 9, 1987    IFP 0.5 Users Manual                  35
  2037.  
  2038.  
  2039. _8._4.  _T_a_i_l _R_e_c_u_r_s_i_o_n
  2040.  
  2041.  
  2042.      Regrettably, the IFP  interpreter  currently  does  not
  2043.  
  2044. recognize tail recursions as iterations.  Thus near-infinite
  2045.  
  2046. recursions will cause a stack overflow.  If this is a  prob-
  2047.  
  2048. lem,  rewrite the function with the WHILE functional form to
  2049.  
  2050. remove the tail recursion.
  2051.  
  2052.  
  2053.      For example, consider the tail recursive function:
  2054.  
  2055.        DEF f AS
  2056.         IF p THEN g
  2057.         ELSE h | f          (* tail recursion *)
  2058.         END;
  2059.  
  2060. We can rewrite is as:
  2061.  
  2062.         DEF f AS
  2063.              WHILE p|~ DO h END | g;
  2064.  
  2065.  
  2066. _9.  _I_n_s_t_a_l_l_a_t_i_o_n _N_o_t_e_s
  2067.  
  2068.  
  2069. _9._1.  _M_a_c_h_i_n_e _D_e_p_e_n_d_e_n_c_e
  2070.  
  2071.  
  2072.      The IFP interpreter is machine independent, as long  as
  2073.  
  2074. your  machine  has 32-bit two's complement integers and IEEE
  2075.  
  2076. floating point.  If not, you  should  take  a  look  at  the
  2077.  
  2078. struct.h  and F_arith.c source files.  The struct.h file de-
  2079.  
  2080. fines all the principle types and  limit  definitions  (e.g.
  2081.  
  2082. MaxInt,  MAXFLOAT).   The  F_arith.c contains the arithmetic
  2083.  
  2084. functions.  See the comments in the code for details.
  2085.  
  2086.  
  2087.  
  2088.  
  2089. February 9, 1987    IFP 0.5 Users Manual                  36
  2090.  
  2091.  
  2092. _9._2.  _C_o_m_p_i_l_i_n_g _O_p_t_i_o_n_s
  2093.  
  2094.  
  2095.      Look in the Makefile and "struct.h" for  possible  com-
  2096.  
  2097. piling  options.   Not  all  options  are  available  in all
  2098.  
  2099. releases.  Normally, the release version comes ready to com-
  2100.  
  2101. pile  on UNIX boxes.  For MSDOS, you will have to modify the
  2102.  
  2103. Makefile and change the OPSYS variable in ``struct.h''.  The
  2104.  
  2105. graphics  interface  is  extremely machine dependent, though
  2106.  
  2107. should not be difficult to modify it for other machines.
  2108.  
  2109.  
  2110.  
  2111.  
  2112. February 9, 1987    IFP 0.5 Users Manual                  37
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132. ____________________
  2133.  
  2134.  
  2135. Bac78a.
  2136.      John Backus, "Can Programming Be Liberated from the von
  2137.      Neumann  Style?   A Functional Style and Its Algebra of
  2138.      Programs," _C_A_C_M  Vol.  21,8 pp.  613-641  ACM,  (August
  2139.      1978).
  2140.  
  2141. Rob87a.
  2142.      Arch  D.  Robison,  "A  Functional  Programming  Inter-
  2143.      preter,"   _T_H_E_S_I_S,  University  of  Illinois,  (January
  2144.      1987).
  2145.  
  2146. Rob87b.
  2147.      Arch D. Robison, "Illinois  Functional  Programming:  A
  2148.      Tutorial," _B_Y_T_E Vol. 12,2 pp. 115-125 McGraw-Hill Inc.,
  2149.      (February 1987).
  2150.  
  2151. Bad83a.
  2152.      Scott Baden, "Berkeley FP  User's  Manual,  Rev.  4.1,"
  2153.      _U_N_I_X _P_r_o_g_r_a_m_m_e_r_s _M_a_n_u_a_l, (July 27,1983).
  2154.  
  2155. Dar82a.
  2156.      J. Darlington, J.V. Guttag, P. Henderson, J.H.  Morris,
  2157.      J.E.Stoy,  G.J.  Sussman,  P.C. Treleaven, D.A. Turner,
  2158.      J.H. Williams, and D.S.  Wise,  _F_u_n_c_t_i_o_n_a_l  _P_r_o_g_r_a_m_m_i_n_g
  2159.      _a_n_d   _i_t_s   _A_p_p_l_i_c_a_t_i_o_n_s,  Cambridge  University  Press
  2160.      (1982).
  2161.  
  2162. Bac81a.
  2163.      John Backus, "The Algebra of Functional Programs: Func-
  2164.      tional  Level Reasoning, Linear Equations, and Extended
  2165.      Definitions," in _F_o_r_m_a_l_i_z_a_t_i_o_n _o_f _P_r_o_g_r_a_m_m_i_n_g _C_o_n_c_e_p_t_s,
  2166.      Springer Verlag,  New York (1981).
  2167.