gh_list.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* Copyright (C) 1995,1996,1997, 2000, 2001, 2004, 2006, 2008 Free Software Foundation, Inc.
  2. * This library is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU Lesser General Public
  4. * License as published by the Free Software Foundation; either
  5. * version 2.1 of the License, or (at your option) any later version.
  6. *
  7. * This library 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 GNU
  10. * Lesser General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU Lesser General Public
  13. * License along with this library; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  15. */
  16. #ifdef HAVE_CONFIG_H
  17. # include <config.h>
  18. #endif
  19. /* list manipulation */
  20. #include "libguile/gh.h"
  21. #if SCM_ENABLE_DEPRECATED
  22. /* returns the length of a list */
  23. unsigned long
  24. gh_length (SCM l)
  25. {
  26. return gh_scm2ulong (scm_length (l));
  27. }
  28. /* list operations */
  29. /* gh_list(SCM elt, ...) is implemented as a macro in gh.h. */
  30. /* gh_append() takes a args, which is a list of lists, and appends
  31. them all together into a single list, which is returned. This is
  32. equivalent to the Scheme procedure (append list1 list2 ...) */
  33. SCM
  34. gh_append (SCM args)
  35. {
  36. return scm_append (args);
  37. }
  38. SCM
  39. gh_append2 (SCM l1, SCM l2)
  40. {
  41. return scm_append (scm_list_2 (l1, l2));
  42. }
  43. SCM
  44. gh_append3(SCM l1, SCM l2, SCM l3)
  45. {
  46. return scm_append (scm_list_3 (l1, l2, l3));
  47. }
  48. SCM
  49. gh_append4 (SCM l1, SCM l2, SCM l3, SCM l4)
  50. {
  51. return scm_append (scm_list_4 (l1, l2, l3, l4));
  52. }
  53. /* gh_reverse() is defined as a macro in gh.h */
  54. /* gh_list_tail() is defined as a macro in gh.h */
  55. /* gh_list_ref() is defined as a macro in gh.h */
  56. /* gh_memq() is defined as a macro in gh.h */
  57. /* gh_memv() is defined as a macro in gh.h */
  58. /* gh_member() is defined as a macro in gh.h */
  59. /* gh_assq() is defined as a macro in gh.h */
  60. /* gh_assv() is defined as a macro in gh.h */
  61. /* gh_assoc() is defined as a macro in gh.h */
  62. /* analogous to the Scheme cons operator */
  63. SCM
  64. gh_cons (SCM x, SCM y)
  65. {
  66. return scm_cons (x, y);
  67. }
  68. /* analogous to the Scheme car operator */
  69. SCM
  70. gh_car (SCM x)
  71. {
  72. return scm_car (x);
  73. }
  74. /* analogous to the Scheme cdr operator */
  75. SCM
  76. gh_cdr (SCM x)
  77. {
  78. return scm_cdr (x);
  79. }
  80. /* now for the multiple car/cdr utility procedures */
  81. SCM
  82. gh_caar (SCM x)
  83. {
  84. return scm_caar (x);
  85. }
  86. SCM
  87. gh_cadr (SCM x)
  88. {
  89. return scm_cadr (x);
  90. }
  91. SCM
  92. gh_cdar (SCM x)
  93. {
  94. return scm_cdar (x);
  95. }
  96. SCM
  97. gh_cddr (SCM x)
  98. {
  99. return scm_cddr (x);
  100. }
  101. SCM
  102. gh_caaar (SCM x)
  103. {
  104. return scm_caaar (x);
  105. }
  106. SCM
  107. gh_caadr (SCM x)
  108. {
  109. return scm_caadr (x);
  110. }
  111. SCM
  112. gh_cadar (SCM x)
  113. {
  114. return scm_cadar (x);
  115. }
  116. SCM
  117. gh_caddr (SCM x)
  118. {
  119. return scm_caddr (x);
  120. }
  121. SCM
  122. gh_cdaar (SCM x)
  123. {
  124. return scm_cdaar (x);
  125. }
  126. SCM
  127. gh_cdadr (SCM x)
  128. {
  129. return scm_cdadr (x);
  130. }
  131. SCM
  132. gh_cddar (SCM x)
  133. {
  134. return scm_cddar (x);
  135. }
  136. SCM
  137. gh_cdddr (SCM x)
  138. {
  139. return scm_cdddr (x);
  140. }
  141. /* equivalent to (set-car! pair value) */
  142. SCM
  143. gh_set_car_x(SCM pair, SCM value)
  144. {
  145. return scm_set_car_x(pair, value);
  146. }
  147. /* equivalent to (set-cdr! pair value) */
  148. SCM
  149. gh_set_cdr_x(SCM pair, SCM value)
  150. {
  151. return scm_set_cdr_x(pair, value);
  152. }
  153. #endif /* SCM_ENABLE_DEPRECATED */
  154. /*
  155. Local Variables:
  156. c-file-style: "gnu"
  157. End:
  158. */