gh_list.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /* Copyright (C) 1995,1996,1997, 2000, 2001 Free Software Foundation, Inc.
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2, or (at your option)
  5. * any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this software; see the file COPYING. If not, write to
  14. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. * Boston, MA 02110-1301 USA
  16. *
  17. * As a special exception, the Free Software Foundation gives permission
  18. * for additional uses of the text contained in its release of GUILE.
  19. *
  20. * The exception is that, if you link the GUILE library with other files
  21. * to produce an executable, this does not by itself cause the
  22. * resulting executable to be covered by the GNU General Public License.
  23. * Your use of that executable is in no way restricted on account of
  24. * linking the GUILE library code into it.
  25. *
  26. * This exception does not however invalidate any other reasons why
  27. * the executable file might be covered by the GNU General Public License.
  28. *
  29. * This exception applies only to the code released by the
  30. * Free Software Foundation under the name GUILE. If you copy
  31. * code from other Free Software Foundation releases into a copy of
  32. * GUILE, as the General Public License permits, the exception does
  33. * not apply to the code that you add in this way. To avoid misleading
  34. * anyone as to the status of such modified files, you must delete
  35. * this exception notice from them.
  36. *
  37. * If you write modifications of your own for GUILE, it is your choice
  38. * whether to permit this exception to apply to your modifications.
  39. * If you do not wish that, delete this exception notice. */
  40. /* list manipulation */
  41. #include "libguile/gh.h"
  42. /* returns the length of a list */
  43. unsigned long
  44. gh_length (SCM l)
  45. {
  46. return gh_scm2ulong (scm_length (l));
  47. }
  48. /* list operations */
  49. /* gh_list(SCM elt, ...) is implemented as a macro in gh.h. */
  50. /* gh_append() takes a args, which is a list of lists, and appends
  51. them all together into a single list, which is returned. This is
  52. equivalent to the Scheme procedure (append list1 list2 ...) */
  53. SCM
  54. gh_append (SCM args)
  55. {
  56. return scm_append (args);
  57. }
  58. SCM
  59. gh_append2 (SCM l1, SCM l2)
  60. {
  61. return scm_append (scm_list_2 (l1, l2));
  62. }
  63. SCM
  64. gh_append3(SCM l1, SCM l2, SCM l3)
  65. {
  66. return scm_append (scm_list_3 (l1, l2, l3));
  67. }
  68. SCM
  69. gh_append4 (SCM l1, SCM l2, SCM l3, SCM l4)
  70. {
  71. return scm_append (scm_list_4 (l1, l2, l3, l4));
  72. }
  73. /* gh_reverse() is defined as a macro in gh.h */
  74. /* gh_list_tail() is defined as a macro in gh.h */
  75. /* gh_list_ref() is defined as a macro in gh.h */
  76. /* gh_memq() is defined as a macro in gh.h */
  77. /* gh_memv() is defined as a macro in gh.h */
  78. /* gh_member() is defined as a macro in gh.h */
  79. /* gh_assq() is defined as a macro in gh.h */
  80. /* gh_assv() is defined as a macro in gh.h */
  81. /* gh_assoc() is defined as a macro in gh.h */
  82. /* analogous to the Scheme cons operator */
  83. SCM
  84. gh_cons (SCM x, SCM y)
  85. {
  86. return scm_cons (x, y);
  87. }
  88. /* analogous to the Scheme car operator */
  89. SCM
  90. gh_car (SCM x)
  91. {
  92. return SCM_CAR (x);
  93. }
  94. /* analogous to the Scheme cdr operator */
  95. SCM
  96. gh_cdr (SCM x)
  97. {
  98. return SCM_CDR (x);
  99. }
  100. /* now for the multiple car/cdr utility procedures */
  101. SCM
  102. gh_caar (SCM x)
  103. {
  104. return SCM_CAAR (x);
  105. }
  106. SCM
  107. gh_cadr (SCM x)
  108. {
  109. return SCM_CADR (x);
  110. }
  111. SCM
  112. gh_cdar (SCM x)
  113. {
  114. return SCM_CDAR (x);
  115. }
  116. SCM
  117. gh_cddr (SCM x)
  118. {
  119. return SCM_CDDR (x);
  120. }
  121. SCM
  122. gh_caaar (SCM x)
  123. {
  124. return SCM_CAAAR (x);
  125. }
  126. SCM
  127. gh_caadr (SCM x)
  128. {
  129. return SCM_CAADR (x);
  130. }
  131. SCM
  132. gh_cadar (SCM x)
  133. {
  134. return SCM_CADAR (x);
  135. }
  136. SCM
  137. gh_caddr (SCM x)
  138. {
  139. return SCM_CADDR (x);
  140. }
  141. SCM
  142. gh_cdaar (SCM x)
  143. {
  144. return SCM_CDAAR (x);
  145. }
  146. SCM
  147. gh_cdadr (SCM x)
  148. {
  149. return SCM_CDADR (x);
  150. }
  151. SCM
  152. gh_cddar (SCM x)
  153. {
  154. return SCM_CDDAR (x);
  155. }
  156. SCM
  157. gh_cdddr (SCM x)
  158. {
  159. return SCM_CDDDR (x);
  160. }
  161. /* equivalent to (set-car! pair value) */
  162. SCM
  163. gh_set_car_x(SCM pair, SCM value)
  164. {
  165. return scm_set_car_x(pair, value);
  166. }
  167. /* equivalent to (set-cdr! pair value) */
  168. SCM
  169. gh_set_cdr_x(SCM pair, SCM value)
  170. {
  171. return scm_set_cdr_x(pair, value);
  172. }
  173. /*
  174. Local Variables:
  175. c-file-style: "gnu"
  176. End:
  177. */