*** empty log message ***
[bpt/guile.git] / srfi / srfi-13.scm
CommitLineData
6be07c52
TTN
1;;; srfi-13.scm --- String Library
2
3;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
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
MG
49
50(define-module (srfi srfi-13))
51
4cf75288 52(export
ca003b26
MG
53;;; Predicates
54 ;; string? string-null? <= in the core
55 string-any string-every
56
57;;; Constructors
58 ;; make-string string <= in the core
59 string-tabulate
60
61;;; List/string conversion
62 string->list
63 ;; list->string <= in the core
64 reverse-list->string
65 string-join
66
67;;; Selection
68 ;; string-length string-ref <= in the core
69 string-copy
70 substring/shared
71 string-copy!
72 string-take string-take-right
73 string-drop string-drop-right
74 string-pad string-pad-right
75 string-trim string-trim-right
76 string-trim-both
77
78;;; Modification
79 ;; string-set! <= in the core
80 string-fill!
81
82;;; Comparison
83 string-compare string-compare-ci
84 string= string<>
85 string< string>
86 string<= string>=
87 string-ci= string-ci<>
88 string-ci< string-ci>
89 string-ci<= string-ci>=
fafb71de 90 string-hash string-hash-ci
ca003b26
MG
91
92;;; Prefixes/Suffixes
93 string-prefix-length
94 string-prefix-length-ci
95 string-suffix-length
96 string-suffix-length-ci
97 string-prefix?
98 string-prefix-ci?
99 string-suffix?
100 string-suffix-ci?
101
102;;; Searching
103 string-index string-index-right
104 string-skip string-skip-right
105 string-count
106 string-contains string-contains-ci
107
108;;; Alphabetic case mapping
109
110 string-upcase string-upcase!
111 string-downcase string-downcase!
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 )
143
1b2f40b9
MG
144(cond-expand-provide (current-module) '(srfi-13))
145
dd22a80a 146(load-extension "libguile-srfi-srfi-13-14" "scm_init_srfi_13")
ca003b26
MG
147
148(define string-hash
149 (lambda (s . rest)
150 (let ((bound (if (pair? rest)
151 (or (car rest)
152 871)
153 871))
154 (start (if (and (pair? rest) (pair? (cdr rest)))
155 (cadr rest)
156 0))
157 (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest)))
158 (caddr rest)
159 (string-length s))))
160 (hash (substring/shared s start end) bound))))
161
162(define string-hash-ci
163 (lambda (s . rest)
164 (let ((bound (if (pair? rest)
165 (or (car rest)
166 871)
167 871))
168 (start (if (and (pair? rest) (pair? (cdr rest)))
169 (cadr rest)
170 0))
171 (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest)))
172 (caddr rest)
173 (string-length s))))
174 (hash (string-upcase (substring/shared s start end)) bound))))
1b2f40b9 175
6be07c52 176;;; srfi-13.scm ends here