List-Transformations.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
  2. <html>
  3. <!-- Created on December 10, 2012 by texi2html 1.82
  4. texi2html was written by:
  5. Lionel Cons <[email protected]> (original author)
  6. Karl Berry <[email protected]>
  7. Olaf Bachmann <[email protected]>
  8. and many others.
  9. Maintained by: Many creative people.
  10. Send bugs and suggestions to <[email protected]>
  11. -->
  12. <head>
  13. <title>avram - a virtual machine code interpreter: 3.1.3 List Transformations</title>
  14. <meta name="description" content="avram - a virtual machine code interpreter: 3.1.3 List Transformations">
  15. <meta name="keywords" content="avram - a virtual machine code interpreter: 3.1.3 List Transformations">
  16. <meta name="resource-type" content="document">
  17. <meta name="distribution" content="global">
  18. <meta name="Generator" content="texi2html 1.82">
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <style type="text/css">
  21. <!--
  22. a.summary-letter {text-decoration: none}
  23. blockquote.smallquotation {font-size: smaller}
  24. pre.display {font-family: serif}
  25. pre.format {font-family: serif}
  26. pre.menu-comment {font-family: serif}
  27. pre.menu-preformatted {font-family: serif}
  28. pre.smalldisplay {font-family: serif; font-size: smaller}
  29. pre.smallexample {font-size: smaller}
  30. pre.smallformat {font-family: serif; font-size: smaller}
  31. pre.smalllisp {font-size: smaller}
  32. span.roman {font-family:serif; font-weight:normal;}
  33. span.sansserif {font-family:sans-serif; font-weight:normal;}
  34. ul.toc {list-style: none}
  35. -->
  36. </style>
  37. </head>
  38. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  39. <a name="List-Transformations"></a>
  40. <table cellpadding="1" cellspacing="1" border="0">
  41. <tr><td valign="middle" align="left">[<a href="Recoverable-Operations.html#Recoverable-Operations" title="Previous section in reading order"> &lt; </a>]</td>
  42. <td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Next section in reading order"> &gt; </a>]</td>
  43. <td valign="middle" align="left"> &nbsp; </td>
  44. <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  45. <td valign="middle" align="left">[<a href="Lists.html#Lists" title="Up section"> Up </a>]</td>
  46. <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> &gt;&gt; </a>]</td>
  47. <td valign="middle" align="left"> &nbsp; </td>
  48. <td valign="middle" align="left"> &nbsp; </td>
  49. <td valign="middle" align="left"> &nbsp; </td>
  50. <td valign="middle" align="left"> &nbsp; </td>
  51. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  52. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  53. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  54. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  55. </tr></table>
  56. <hr size="1">
  57. <a name="List-Transformations-1"></a>
  58. <h3 class="subsection">3.1.3 List Transformations</h3>
  59. <p>Some functions declared in &lsquo;<tt>listfuns.h</tt>&rsquo; are used to implement the
  60. operations described in <a href="List-Functions.html#List-Functions">List Functions</a>. These functions are able
  61. to report error messages in the event of overflow or other exceptional
  62. <a name="index-overflow-3"></a>
  63. <a name="index-exceptions-4"></a>
  64. <a name="index-error-messages-2"></a>
  65. conditions, as described in <a href="Error-Messages.html#Error-Messages">Error Messages</a>. The error messages are
  66. represented as lists and returned to the caller. The occurrence of an
  67. error can be detected by the <code>*<var>fault</var></code> flag being set to a
  68. non-zero value. None of these functions ever causes a program exit except
  69. in the event of an internal error.
  70. </p>
  71. <dl>
  72. <dt><a name="index-avm_005finitialize_005flistfuns"></a><u>Function:</u> void <b>avm_initialize_listfuns</b><i> ()</i></dt>
  73. <dd><p>This has to be called before any of the other functions in this section
  74. is called. It initializes the error message lists, among other things.
  75. </p></dd></dl>
  76. <dl>
  77. <dt><a name="index-avm_005fcount_005flistfuns"></a><u>Function:</u> void <b>avm_count_listfuns</b><i> ()</i></dt>
  78. <dd><p>At the end of a run, a call to this function can verify that no
  79. unreclaimed storage attributable to these functions persists. If it
  80. does, a warning is printed to standard error. If <code>avm_count_lists</code>
  81. is also used, it must be called after this function.
  82. </p></dd></dl>
  83. <dl>
  84. <dt><a name="index-avm_005freversal"></a><u>Function:</u> list <b>avm_reversal</b><i> (list <var>operand</var>, int *<var>fault</var>)</i></dt>
  85. <dd><p>The reversal of the list is returned by this function if no overflow
  86. occurs. A non-zero <code>*<var>fault</var></code> and an error message are returned
  87. otherwise. The original <code><var>operand</var></code> still exists in its original
  88. order after this function is called. The amount of additional storage
  89. allocated is proportional only to the length of the list, not the size
  90. of its contents.
  91. </p></dd></dl>
  92. <dl>
  93. <dt><a name="index-avm_005fdistribution"></a><u>Function:</u> list <b>avm_distribution</b><i> (list <var>operand</var>, int *<var>fault</var>)</i></dt>
  94. <dd><p>This function performs the operation described in <a href="Distribute.html#Distribute">Distribute</a>. The
  95. invalid distribution message is returned in the event of a <code>NULL</code>
  96. operand. Otherwise, the returned value is the distributed list. In any event,
  97. the <code><var>operand</var></code> is unaffected.
  98. </p></dd></dl>
  99. <dl>
  100. <dt><a name="index-avm_005fconcatenation"></a><u>Function:</u> list <b>avm_concatenation</b><i> (list <var>operand</var>, int *<var>fault</var>)</i></dt>
  101. <dd><a name="index-concatenation-2"></a>
  102. <p>The <code><var>operand</var></code> is treated as a pair of lists to be concatenated, with the
  103. left one in the <code>head</code> field and the right one in the <code>tail</code>
  104. field. The invalid concatenation message is returned in the event of a
  105. <code>NULL</code> <code><var>operand</var></code>. The result returned otherwise is the concatenation
  106. of the lists, but the given <code><var>operand</var></code> still exists unchanged.
  107. </p></dd></dl>
  108. <dl>
  109. <dt><a name="index-avm_005ftransposition"></a><u>Function:</u> list <b>avm_transposition</b><i> (list <var>operand</var>, int *<var>fault</var>)</i></dt>
  110. <dd><p>The operation performed by this function corresponds to that of
  111. <a href="Transpose.html#Transpose">Transpose</a>. Unlike other functions in this section, the operand
  112. passed to this function is deallocated, and must not be referenced
  113. <a name="index-transpose-2"></a>
  114. thereafter. The transposed list is accessible as the returned value of
  115. this function. If the original <code><var>operand</var></code> is still needed
  116. after a call to <code>avm_transposition</code>, only a copy of it should be
  117. passed to it, obtained from <code>avm_copied</code>. The invalid transpose
  118. error message is the result if the operand does not represent a list of equal
  119. length lists.
  120. </p></dd></dl>
  121. <dl>
  122. <dt><a name="index-avm_005fmembership"></a><u>Function:</u> list <b>avm_membership</b><i> (list <var>operand</var>, int *<var>fault</var>)</i></dt>
  123. <dd><p>This function computes the membership predicate described in
  124. <a name="index-member-1"></a>
  125. <a href="Member.html#Member">Member</a>. The operand is a list in which the <code>tail</code> field is
  126. a list that will be searched for the item in the <code>head</code>. If the
  127. item is not found, a <code>NULL</code> list is returned, but otherwise a list
  128. with <code>NULL</code> <code>head</code> and <code>tail</code> fields is returned. If the
  129. operand is <code>NULL</code>, an error message of invalid membership is
  130. returned and <code>*<var>fault</var></code> is set to a non-zero value.
  131. </p>
  132. <p>The <code>avm_membership</code> function calls <code>avm_binary_comparison</code>
  133. in order to compare lists, so the same efficiency and side-effect
  134. considerations are relevant to both (<a href="Comparison.html#Comparison">Comparison</a>). It is not
  135. necessary to <code>#include</code> the header file <code>compare.h</code> or to
  136. call <code>avm_initialize_compare</code> in order to use
  137. <code>avm_membership</code>, because they will be done automatically.
  138. </p></dd></dl>
  139. <dl>
  140. <dt><a name="index-avm_005fbinary_005fmembership"></a><u>Function:</u> list <b>avm_binary_membership</b><i> (list <var>operand</var>, list <var>members</var>, int *<var>fault</var>);</i></dt>
  141. <dd><p>This function is the same as <code>avm_membership</code> except that it
  142. allows the element and the set of members to be passed as separate
  143. lists instead of being the head and the tail of the same list.
  144. </p></dd></dl>
  145. <dl>
  146. <dt><a name="index-avm_005fmeasurement"></a><u>Function:</u> list <b>avm_measurement</b><i> (list <var>operand</var>, int *<var>fault</var>)</i></dt>
  147. <dd><p>This function implements the operation described in <a href="Weight.html#Weight">Weight</a>, which
  148. pertains to the weight of a tree. The returned value of this function is
  149. a list encoding the weight as a binary number, unless a counter overflow
  150. occurs, in which case it&rsquo;s an error message. As noted previously, the
  151. weight of a tree can easily be exponentially larger than the amount of
  152. <a name="index-native-integer-arithmetic-1"></a>
  153. memory it occupies, but this function uses native integer arithmetic for
  154. performance reasons. Hence, a counter overflow is a real
  155. possibility.
  156. </p></dd></dl>
  157. <hr size="1">
  158. <table cellpadding="1" cellspacing="1" border="0">
  159. <tr><td valign="middle" align="left">[<a href="Recoverable-Operations.html#Recoverable-Operations" title="Previous section in reading order"> &lt; </a>]</td>
  160. <td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Next section in reading order"> &gt; </a>]</td>
  161. <td valign="middle" align="left"> &nbsp; </td>
  162. <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  163. <td valign="middle" align="left">[<a href="Lists.html#Lists" title="Up section"> Up </a>]</td>
  164. <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> &gt;&gt; </a>]</td>
  165. <td valign="middle" align="left"> &nbsp; </td>
  166. <td valign="middle" align="left"> &nbsp; </td>
  167. <td valign="middle" align="left"> &nbsp; </td>
  168. <td valign="middle" align="left"> &nbsp; </td>
  169. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  170. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  171. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  172. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  173. </tr></table>
  174. <p>
  175. <font size="-1">
  176. This document was generated on <i>December 10, 2012</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
  177. </font>
  178. <br>
  179. </p>
  180. </body>
  181. </html>