Pairwise.html 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <html lang="en">
  2. <head>
  3. <title>Pairwise - 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="Reference-Implementations.html#Reference-Implementations" title="Reference Implementations">
  10. <link rel="next" href="Insert.html#Insert" title="Insert">
  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="Pairwise"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Insert.html#Insert">Insert</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="Reference-Implementations.html#Reference-Implementations">Reference Implementations</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.1 Pairwise</h3>
  35. <p><a name="index-g_t_0040code_007bpairwise_007d-699"></a>This <code>silly</code> code fragment is mentioned in <a href="Reduce.html#Reduce">Reduce</a>, in the
  36. discussion of <code>reduce</code>, and is provided as an example of a solution
  37. to equations <em>E1</em> to <em>E3</em>. It is written in the style of a
  38. higher order function, in that it takes a function <var>f</var> as an
  39. argument and returns another function, [[<code>pairwise</code>]]
  40. <var>f</var> as a result.
  41. <pre class="example">
  42. self = left
  43. argument = right
  44. head = left
  45. tail = right
  46. pairwise =
  47. compose(
  48. refer,
  49. compose(
  50. bu(
  51. conditional,
  52. conditional(argument,compose(tail,argument),constant nil)),
  53. couple(
  54. (hired couple)(
  55. (hired compose)(
  56. identity,
  57. constant (hired fan head)(
  58. argument,
  59. compose(tail,argument))),
  60. constant (hired meta)(
  61. self,
  62. compose(tail,compose(tail,argument)))),
  63. constant argument)))
  64. </pre>
  65. <p class="noindent">To see how this works, one should evaluate it symbolically with an
  66. unknown <var>f</var>, which will result in some <code>silly</code>
  67. pseudocode, and then evaluate that symbolically with some sample lists.
  68. </body></html>