Commit | Line | Data |
---|---|---|
6be07c52 TTN |
1 | ;;; srfi-13.scm --- String Library |
2 | ||
d57da08b | 3 | ;; Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. |
6be07c52 TTN |
4 | ;; |
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. | |
9 | ;; | |
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. | |
14 | ;; | |
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 | |
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. | |
0706ae06 TTN |
43 | |
44 | ;;; Commentary: | |
45 | ||
46 | ;; This module is fully documented in the Guile Reference Manual. | |
47 | ||
48 | ;;; Code: | |
ca003b26 | 49 | |
d57da08b MD |
50 | (define-module (srfi srfi-13) |
51 | :export ( | |
ca003b26 MG |
52 | ;;; Predicates |
53 | ;; string? string-null? <= in the core | |
54 | string-any string-every | |
55 | ||
56 | ;;; Constructors | |
57 | ;; make-string string <= in the core | |
58 | string-tabulate | |
59 | ||
60 | ;;; List/string conversion | |
d57da08b | 61 | ;; string->list extended |
ca003b26 MG |
62 | ;; list->string <= in the core |
63 | reverse-list->string | |
64 | string-join | |
65 | ||
66 | ;;; Selection | |
67 | ;; string-length string-ref <= in the core | |
d57da08b | 68 | ;; string-copy extended |
ca003b26 MG |
69 | substring/shared |
70 | string-copy! | |
71 | string-take string-take-right | |
72 | string-drop string-drop-right | |
73 | string-pad string-pad-right | |
74 | string-trim string-trim-right | |
75 | string-trim-both | |
76 | ||
77 | ;;; Modification | |
78 | ;; string-set! <= in the core | |
d57da08b | 79 | ;; string-fill! extended |
ca003b26 MG |
80 | |
81 | ;;; Comparison | |
82 | string-compare string-compare-ci | |
83 | string= string<> | |
84 | string< string> | |
85 | string<= string>= | |
86 | string-ci= string-ci<> | |
87 | string-ci< string-ci> | |
88 | string-ci<= string-ci>= | |
fafb71de | 89 | string-hash string-hash-ci |
ca003b26 MG |
90 | |
91 | ;;; Prefixes/Suffixes | |
92 | string-prefix-length | |
93 | string-prefix-length-ci | |
94 | string-suffix-length | |
95 | string-suffix-length-ci | |
96 | string-prefix? | |
97 | string-prefix-ci? | |
98 | string-suffix? | |
99 | string-suffix-ci? | |
100 | ||
101 | ;;; Searching | |
d57da08b MD |
102 | ;; string-index extended |
103 | string-index-right | |
ca003b26 MG |
104 | string-skip string-skip-right |
105 | string-count | |
106 | string-contains string-contains-ci | |
107 | ||
108 | ;;; Alphabetic case mapping | |
109 | ||
d57da08b MD |
110 | ;; string-upcase string-upcase! extended |
111 | ;; string-downcase string-downcase! extended | |
ca003b26 MG |
112 | string-titlecase string-titlecase! |
113 | ||
114 | ;;; Reverse/Append | |
115 | string-reverse string-reverse! | |
116 | ;; string-append <= in the core | |
117 | string-append/shared | |
118 | string-concatenate | |
8dddb4bc | 119 | string-concatenate-reverse |
ca003b26 | 120 | string-concatenate/shared |
8dddb4bc | 121 | string-concatenate-reverse/shared |
ca003b26 MG |
122 | |
123 | ;;; Fold/Unfold/Map | |
124 | string-map string-map! | |
125 | string-fold | |
126 | string-fold-right | |
127 | string-unfold | |
128 | string-unfold-right | |
129 | string-for-each | |
4cf75288 | 130 | string-for-each-index |
ca003b26 MG |
131 | |
132 | ;;; Replicate/Rotate | |
133 | xsubstring string-xcopy! | |
134 | ||
135 | ;;; Miscellaneous | |
136 | string-replace | |
137 | string-tokenize | |
138 | ||
139 | ;;; Filtering/Deleting | |
140 | string-filter | |
141 | string-delete | |
142 | ) | |
d57da08b MD |
143 | :replace (string->list string-copy string-fill! |
144 | string-upcase! string-upcase string-downcase! string-downcase | |
145 | string-index) | |
146 | ) | |
ca003b26 | 147 | |
1b2f40b9 MG |
148 | (cond-expand-provide (current-module) '(srfi-13)) |
149 | ||
dd22a80a | 150 | (load-extension "libguile-srfi-srfi-13-14" "scm_init_srfi_13") |
ca003b26 MG |
151 | |
152 | (define string-hash | |
153 | (lambda (s . rest) | |
154 | (let ((bound (if (pair? rest) | |
155 | (or (car rest) | |
156 | 871) | |
157 | 871)) | |
158 | (start (if (and (pair? rest) (pair? (cdr rest))) | |
159 | (cadr rest) | |
160 | 0)) | |
161 | (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest))) | |
162 | (caddr rest) | |
163 | (string-length s)))) | |
164 | (hash (substring/shared s start end) bound)))) | |
165 | ||
166 | (define string-hash-ci | |
167 | (lambda (s . rest) | |
168 | (let ((bound (if (pair? rest) | |
169 | (or (car rest) | |
170 | 871) | |
171 | 871)) | |
172 | (start (if (and (pair? rest) (pair? (cdr rest))) | |
173 | (cadr rest) | |
174 | 0)) | |
175 | (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest))) | |
176 | (caddr rest) | |
177 | (string-length s)))) | |
178 | (hash (string-upcase (substring/shared s start end)) bound)))) | |
1b2f40b9 | 179 | |
6be07c52 | 180 | ;;; srfi-13.scm ends here |