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