Insert.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <html lang="en">
  2. <head>
  3. <title>Insert - avram - a virtual machine code interpreter</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="avram - a virtual machine code interpreter">
  6. <meta name="generator" content="makeinfo 4.13">
  7. <link title="Top" rel="start" href="index.html#Top">
  8. <link rel="up" href="Reference-Implementations.html#Reference-Implementations" title="Reference Implementations">
  9. <link rel="prev" href="Pairwise.html#Pairwise" title="Pairwise">
  10. <link rel="next" href="Replace.html#Replace" title="Replace">
  11. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  12. <meta http-equiv="Content-Style-Type" content="text/css">
  13. <style type="text/css"><!--
  14. pre.display { font-family:inherit }
  15. pre.format { font-family:inherit }
  16. pre.smalldisplay { font-family:inherit; font-size:smaller }
  17. pre.smallformat { font-family:inherit; font-size:smaller }
  18. pre.smallexample { font-size:smaller }
  19. pre.smalllisp { font-size:smaller }
  20. span.sc { font-variant:small-caps }
  21. span.roman { font-family:serif; font-weight:normal; }
  22. span.sansserif { font-family:sans-serif; font-weight:normal; }
  23. --></style>
  24. </head>
  25. <body>
  26. <div class="node">
  27. <a name="Insert"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Replace.html#Replace">Replace</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="Pairwise.html#Pairwise">Pairwise</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="Reference-Implementations.html#Reference-Implementations">Reference Implementations</a>
  32. <hr>
  33. </div>
  34. <h3 class="section">B.2 Insert</h3>
  35. <p><a name="index-g_t_0040code_007binsert_007d-700"></a>This function is mentioned in <a href="Sort.html#Sort">Sort</a>, on sorting. It takes the
  36. virtual code for a partial order relational operator and returns the
  37. code for a function of two arguments. The left argument is a list item
  38. and the right argument is a list of items of the same type, which is
  39. already sorted with respect to the relational operator given as the
  40. argument to <code>insert</code>. The result of the function returned by
  41. <code>insert</code> is a list similar to its right argument but with the left
  42. argument inserted in the proper position to maintain the order.
  43. <p>This code makes use of the <code>self</code>, <code>argument</code>, <code>head</code>
  44. and <code>tail</code> declarations associated with <code>pairwise</code>.
  45. <pre class="example">
  46. insert =
  47. bu(compose,refer) (hired conditional)(
  48. constant compose(right,argument),
  49. couple(
  50. (hired conditional)(
  51. (hired compose)(
  52. identity,
  53. constant compose(
  54. couple(left,compose(head,right)),
  55. argument)),
  56. constant (
  57. argument,
  58. couple(
  59. compose(head,compose(right,argument)),
  60. (hired meta)(
  61. self,
  62. couple(
  63. compose(left,argument),
  64. compose(tail,compose(right,argument))))))),
  65. constant argument))
  66. </pre>
  67. <p>As with the other higher order functions in this appendix, the only
  68. feasible ways to verify it would be either by formal proof or by some
  69. form of symbolic interpretation.
  70. </body></html>