Compare.html 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <html lang="en">
  2. <head>
  3. <title>Compare - 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="Predicates.html#Predicates" title="Predicates">
  9. <link rel="prev" href="Predicates.html#Predicates" title="Predicates">
  10. <link rel="next" href="Member.html#Member" title="Member">
  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="Compare"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Member.html#Member">Member</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="Predicates.html#Predicates">Predicates</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="Predicates.html#Predicates">Predicates</a>
  32. <hr>
  33. </div>
  34. <h5 class="subsubsection">2.7.11.1 Compare</h5>
  35. <p><a name="index-g_t_0040code_007bcompare_007d-311"></a>A function that performs comparison has a the following very simple
  36. virtual code representation.
  37. <dl>
  38. <dt><em>T19</em><dd>[[<code>compare</code>]] = <code>(nil,nil)</code>
  39. </dl>
  40. <p class="noindent">The proof of theorem <em>T19</em> is that the standard <code>silly</code> prelude
  41. contains the declaration <code>compare = (nil,nil)</code>. Code in this form
  42. has the following semantics.
  43. <dl>
  44. <dt><em>P17</em><dd>For distinct trees <var>x</var> and <var>y</var>, [[<code>compare</code>]] <code>(</code><var>x</var><code>,</code><var>y</var><code>)</code> = <code>nil</code>
  45. <br><dt><em>P18</em><dd>[[<code>compare</code>]] <code>(</code><var>x</var><code>,</code><var>x</var><code>)</code> = <code>(nil,nil)</code>
  46. </dl>
  47. <p class="noindent"><a name="index-equality-312"></a>In other words, the virtual code <code>(nil,nil)</code> implements a function
  48. that takes a pair of trees and returns true if and only if they are
  49. equal.
  50. <p>It would be fairly simple to write an equivalent virtual code
  51. application that implements this function if it were not realizable in
  52. this form by definition of the operator. However, this method is
  53. preferable because it saves space in virtual code and has a highly
  54. optimized implementation in C.
  55. </body></html>