*** empty log message ***
[bpt/guile.git] / srfi / srfi-13.scm
CommitLineData
ca003b26
MG
1;;;; srfi-13.scm --- SRFI-13 procedures for Guile
2;;;;
3;;;; Copyright (C) 2001 Free Software Foundation, Inc.
4cf75288 4;;;;
ca003b26
MG
5;;;; This program is free software; you can redistribute it and/or
6;;;; modify it under the terms of the GNU General Public License as
7;;;; published by the Free Software Foundation; either version 2, or
8;;;; (at your option) any later version.
4cf75288 9;;;;
ca003b26
MG
10;;;; This program is distributed in the hope that it will be useful,
11;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13;;;; General Public License for more details.
4cf75288 14;;;;
ca003b26
MG
15;;;; You should have received a copy of the GNU General Public License
16;;;; along with this software; see the file COPYING. If not, write to
17;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18;;;; Boston, MA 02111-1307 USA
f480396b
MV
19;;;;
20;;;; As a special exception, the Free Software Foundation gives permission
21;;;; for additional uses of the text contained in its release of GUILE.
22;;;;
23;;;; The exception is that, if you link the GUILE library with other files
24;;;; to produce an executable, this does not by itself cause the
25;;;; resulting executable to be covered by the GNU General Public License.
26;;;; Your use of that executable is in no way restricted on account of
27;;;; linking the GUILE library code into it.
28;;;;
29;;;; This exception does not however invalidate any other reasons why
30;;;; the executable file might be covered by the GNU General Public License.
31;;;;
32;;;; This exception applies only to the code released by the
33;;;; Free Software Foundation under the name GUILE. If you copy
34;;;; code from other Free Software Foundation releases into a copy of
35;;;; GUILE, as the General Public License permits, the exception does
36;;;; not apply to the code that you add in this way. To avoid misleading
37;;;; anyone as to the status of such modified files, you must delete
38;;;; this exception notice from them.
39;;;;
40;;;; If you write modifications of your own for GUILE, it is your choice
41;;;; whether to permit this exception to apply to your modifications.
42;;;; If you do not wish that, delete this exception notice.
ca003b26
MG
43
44(define-module (srfi srfi-13))
45
4cf75288 46(export
ca003b26
MG
47;;; Predicates
48 ;; string? string-null? <= in the core
49 string-any string-every
50
51;;; Constructors
52 ;; make-string string <= in the core
53 string-tabulate
54
55;;; List/string conversion
56 string->list
57 ;; list->string <= in the core
58 reverse-list->string
59 string-join
60
61;;; Selection
62 ;; string-length string-ref <= in the core
63 string-copy
64 substring/shared
65 string-copy!
66 string-take string-take-right
67 string-drop string-drop-right
68 string-pad string-pad-right
69 string-trim string-trim-right
70 string-trim-both
71
72;;; Modification
73 ;; string-set! <= in the core
74 string-fill!
75
76;;; Comparison
77 string-compare string-compare-ci
78 string= string<>
79 string< string>
80 string<= string>=
81 string-ci= string-ci<>
82 string-ci< string-ci>
83 string-ci<= string-ci>=
fafb71de 84 string-hash string-hash-ci
ca003b26
MG
85
86;;; Prefixes/Suffixes
87 string-prefix-length
88 string-prefix-length-ci
89 string-suffix-length
90 string-suffix-length-ci
91 string-prefix?
92 string-prefix-ci?
93 string-suffix?
94 string-suffix-ci?
95
96;;; Searching
97 string-index string-index-right
98 string-skip string-skip-right
99 string-count
100 string-contains string-contains-ci
101
102;;; Alphabetic case mapping
103
104 string-upcase string-upcase!
105 string-downcase string-downcase!
106 string-titlecase string-titlecase!
107
108;;; Reverse/Append
109 string-reverse string-reverse!
110 ;; string-append <= in the core
111 string-append/shared
112 string-concatenate
8dddb4bc 113 string-concatenate-reverse
ca003b26 114 string-concatenate/shared
8dddb4bc 115 string-concatenate-reverse/shared
ca003b26
MG
116
117;;; Fold/Unfold/Map
118 string-map string-map!
119 string-fold
120 string-fold-right
121 string-unfold
122 string-unfold-right
123 string-for-each
4cf75288 124 string-for-each-index
ca003b26
MG
125
126;;; Replicate/Rotate
127 xsubstring string-xcopy!
128
129;;; Miscellaneous
130 string-replace
131 string-tokenize
132
133;;; Filtering/Deleting
134 string-filter
135 string-delete
136 )
137
1b2f40b9
MG
138(cond-expand-provide (current-module) '(srfi-13))
139
dd22a80a 140(load-extension "libguile-srfi-srfi-13-14" "scm_init_srfi_13")
ca003b26
MG
141
142(define string-hash
143 (lambda (s . rest)
144 (let ((bound (if (pair? rest)
145 (or (car rest)
146 871)
147 871))
148 (start (if (and (pair? rest) (pair? (cdr rest)))
149 (cadr rest)
150 0))
151 (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest)))
152 (caddr rest)
153 (string-length s))))
154 (hash (substring/shared s start end) bound))))
155
156(define string-hash-ci
157 (lambda (s . rest)
158 (let ((bound (if (pair? rest)
159 (or (car rest)
160 871)
161 871))
162 (start (if (and (pair? rest) (pair? (cdr rest)))
163 (cadr rest)
164 0))
165 (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest)))
166 (caddr rest)
167 (string-length s))))
168 (hash (string-upcase (substring/shared s start end)) bound))))
1b2f40b9 169