Member.html 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <html lang="en">
  2. <head>
  3. <title>Member - 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="Compare.html#Compare" title="Compare">
  10. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  11. <meta http-equiv="Content-Style-Type" content="text/css">
  12. <style type="text/css"><!--
  13. pre.display { font-family:inherit }
  14. pre.format { font-family:inherit }
  15. pre.smalldisplay { font-family:inherit; font-size:smaller }
  16. pre.smallformat { font-family:inherit; font-size:smaller }
  17. pre.smallexample { font-size:smaller }
  18. pre.smalllisp { font-size:smaller }
  19. span.sc { font-variant:small-caps }
  20. span.roman { font-family:serif; font-weight:normal; }
  21. span.sansserif { font-family:sans-serif; font-weight:normal; }
  22. --></style>
  23. </head>
  24. <body>
  25. <div class="node">
  26. <a name="Member"></a>
  27. <p>
  28. Previous:&nbsp;<a rel="previous" accesskey="p" href="Compare.html#Compare">Compare</a>,
  29. Up:&nbsp;<a rel="up" accesskey="u" href="Predicates.html#Predicates">Predicates</a>
  30. <hr>
  31. </div>
  32. <h5 class="subsubsection">2.7.11.2 Member</h5>
  33. <p>Another built in predicate function has the virtual code shown below.
  34. <a name="index-g_t_0040code_007bmember_007d-313"></a>
  35. <dl>
  36. <dt><em>T20</em><dd>[[<code>member</code>]] = <code>((nil,nil),((nil,nil),nil))</code>
  37. </dl>
  38. <p class="noindent">As the mnemonic suggests, the function implemented by this code detects
  39. whether a given item is a member of a list. The left side of its
  40. argument is the item to be detected, and the right side is the list that
  41. may or may not contain it. Lists are represented as explained in
  42. <a href="Representation-of-Numeric-and-Textual-Data.html#Representation-of-Numeric-and-Textual-Data">Representation of Numeric and Textual Data</a>.
  43. <p>The virtual code semantics can be specified by these three properties of
  44. the operator.
  45. <dl>
  46. <dt><em>P19</em><dd>[[<code>member</code>]] <code>(</code><var>x</var><code>,nil)</code> = <code>nil</code>
  47. <br><dt><em>P20</em><dd>[[<code>member</code>]] <code>(</code><var>x</var><code>,(</code><var>x</var><code>,</code><var>y</var><code>))</code> = <code>(nil,nil)</code>
  48. <br><dt><em>P21</em><dd>For distinct trees <var>x</var> and <var>y</var>, [[<code>member</code>]] <code>(</code><var>x</var><code>,(</code><var>y</var><code>,</code><var>z</var><code>))</code> =
  49. [[<code>member</code>]] <code>(</code><var>x</var><code>,z)</code>
  50. </dl>
  51. <p>As in the case of <code>compare</code>, the implementation of <code>member</code> is
  52. well optimized in C, so this form is to be preferred over an ad hoc
  53. construction of a membership testing function in virtual code.
  54. </body></html>