gh_list.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /* Copyright (C) 1995,1996,1997, 2000 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., 59 Temple Place, Suite 330,
  15. * Boston, MA 02111-1307 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 <stdio.h>
  42. #include "libguile/gh.h"
  43. /* returns the length of a list */
  44. unsigned long
  45. gh_length (SCM l)
  46. {
  47. return gh_scm2ulong (scm_length (l));
  48. }
  49. /* list operations */
  50. /* gh_list(SCM elt, ...) is implemented as a macro in gh.h. */
  51. /* gh_append() takes a args, which is a list of lists, and appends
  52. them all together into a single list, which is returned. This is
  53. equivalent to the Scheme procedure (append list1 list2 ...) */
  54. SCM gh_append(SCM args)
  55. {
  56. return scm_append(args);
  57. }
  58. SCM gh_append2(SCM l1, SCM l2)
  59. {
  60. return scm_append(scm_listify(l1, l2, SCM_UNDEFINED));
  61. }
  62. SCM gh_append3(SCM l1, SCM l2, SCM l3)
  63. {
  64. return scm_append(scm_listify(l1, l2, l3, SCM_UNDEFINED));
  65. }
  66. SCM gh_append4(SCM l1, SCM l2, SCM l3, SCM l4)
  67. {
  68. return scm_append(scm_listify(l1, l2, l3, l4, SCM_UNDEFINED));
  69. }
  70. /* gh_reverse() is defined as a macro in gh.h */
  71. /* gh_list_tail() is defined as a macro in gh.h */
  72. /* gh_list_ref() is defined as a macro in gh.h */
  73. /* gh_memq() is defined as a macro in gh.h */
  74. /* gh_memv() is defined as a macro in gh.h */
  75. /* gh_member() is defined as a macro in gh.h */
  76. /* gh_assq() is defined as a macro in gh.h */
  77. /* gh_assv() is defined as a macro in gh.h */
  78. /* gh_assoc() is defined as a macro in gh.h */
  79. /* analogous to the Scheme cons operator */
  80. SCM
  81. gh_cons (SCM x, SCM y)
  82. {
  83. return scm_cons (x, y);
  84. }
  85. /* analogous to the Scheme car operator */
  86. SCM
  87. gh_car (SCM x)
  88. {
  89. return SCM_CAR (x);
  90. }
  91. /* analogous to the Scheme cdr operator */
  92. SCM
  93. gh_cdr (SCM x)
  94. {
  95. return SCM_CDR (x);
  96. }
  97. /* now for the multiple car/cdr utility procedures */
  98. SCM
  99. gh_caar (SCM x)
  100. {
  101. return SCM_CAAR (x);
  102. }
  103. SCM
  104. gh_cadr (SCM x)
  105. {
  106. return SCM_CADR (x);
  107. }
  108. SCM
  109. gh_cdar (SCM x)
  110. {
  111. return SCM_CDAR (x);
  112. }
  113. SCM
  114. gh_cddr (SCM x)
  115. {
  116. return SCM_CDDR (x);
  117. }
  118. SCM
  119. gh_caaar (SCM x)
  120. {
  121. return SCM_CAAAR (x);
  122. }
  123. SCM
  124. gh_caadr (SCM x)
  125. {
  126. return SCM_CAADR (x);
  127. }
  128. SCM
  129. gh_cadar (SCM x)
  130. {
  131. return SCM_CADAR (x);
  132. }
  133. SCM
  134. gh_caddr (SCM x)
  135. {
  136. return SCM_CADDR (x);
  137. }
  138. SCM
  139. gh_cdaar (SCM x)
  140. {
  141. return SCM_CDAAR (x);
  142. }
  143. SCM
  144. gh_cdadr (SCM x)
  145. {
  146. return SCM_CDADR (x);
  147. }
  148. SCM
  149. gh_cddar (SCM x)
  150. {
  151. return SCM_CDDAR (x);
  152. }
  153. SCM
  154. gh_cdddr (SCM x)
  155. {
  156. return SCM_CDDDR (x);
  157. }
  158. /* equivalent to (set-car! pair value) */
  159. SCM
  160. gh_set_car_x(SCM pair, SCM value)
  161. {
  162. return scm_set_car_x(pair, value);
  163. }
  164. /* equivalent to (set-cdr! pair value) */
  165. SCM
  166. gh_set_cdr_x(SCM pair, SCM value)
  167. {
  168. return scm_set_cdr_x(pair, value);
  169. }
  170. /*
  171. Local Variables:
  172. c-file-style: "gnu"
  173. End:
  174. */