*** empty log message ***
[bpt/guile.git] / srfi / srfi-13.scm
1 ;;; srfi-13.scm --- String Library
2
3 ;; Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
4 ;;
5 ;; This library is free software; you can redistribute it and/or
6 ;; modify it under the terms of the GNU Lesser General Public
7 ;; License as published by the Free Software Foundation; either
8 ;; version 2.1 of the License, or (at your option) any later version.
9 ;;
10 ;; This library 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 ;; Lesser General Public License for more details.
14 ;;
15 ;; You should have received a copy of the GNU Lesser General Public
16 ;; License along with this library; if not, write to the Free Software
17 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 ;;; Commentary:
20
21 ;; This module is fully documented in the Guile Reference Manual.
22
23 ;;; Code:
24
25 (define-module (srfi srfi-13)
26 :export (
27 ;;; Predicates
28 ;; string? string-null? <= in the core
29 string-any string-every
30
31 ;;; Constructors
32 ;; make-string string <= in the core
33 string-tabulate
34
35 ;;; List/string conversion
36 ;; string->list extended
37 ;; list->string <= in the core
38 reverse-list->string
39 string-join
40
41 ;;; Selection
42 ;; string-length string-ref <= in the core
43 ;; string-copy extended
44 substring/shared
45 string-copy!
46 string-take string-take-right
47 string-drop string-drop-right
48 string-pad string-pad-right
49 string-trim string-trim-right
50 string-trim-both
51
52 ;;; Modification
53 ;; string-set! <= in the core
54 ;; string-fill! extended
55
56 ;;; Comparison
57 string-compare string-compare-ci
58 string= string<>
59 string< string>
60 string<= string>=
61 string-ci= string-ci<>
62 string-ci< string-ci>
63 string-ci<= string-ci>=
64 string-hash string-hash-ci
65
66 ;;; Prefixes/Suffixes
67 string-prefix-length
68 string-prefix-length-ci
69 string-suffix-length
70 string-suffix-length-ci
71 string-prefix?
72 string-prefix-ci?
73 string-suffix?
74 string-suffix-ci?
75
76 ;;; Searching
77 ;; string-index extended
78 string-index-right
79 string-skip string-skip-right
80 string-count
81 string-contains string-contains-ci
82
83 ;;; Alphabetic case mapping
84
85 ;; string-upcase string-upcase! extended
86 ;; string-downcase string-downcase! extended
87 string-titlecase string-titlecase!
88
89 ;;; Reverse/Append
90 string-reverse string-reverse!
91 ;; string-append <= in the core
92 string-append/shared
93 string-concatenate
94 string-concatenate-reverse
95 string-concatenate/shared
96 string-concatenate-reverse/shared
97
98 ;;; Fold/Unfold/Map
99 string-map string-map!
100 string-fold
101 string-fold-right
102 string-unfold
103 string-unfold-right
104 string-for-each
105 string-for-each-index
106
107 ;;; Replicate/Rotate
108 xsubstring string-xcopy!
109
110 ;;; Miscellaneous
111 string-replace
112 string-tokenize
113
114 ;;; Filtering/Deleting
115 string-filter
116 string-delete
117 )
118 :replace (string->list string-copy string-fill!
119 string-upcase! string-upcase string-downcase! string-downcase
120 string-index)
121 )
122
123 (cond-expand-provide (current-module) '(srfi-13))
124
125 (load-extension "libguile-srfi-srfi-13-14" "scm_init_srfi_13")
126
127 (define string-hash
128 (lambda (s . rest)
129 (let ((bound (if (pair? rest)
130 (or (car rest)
131 871)
132 871))
133 (start (if (and (pair? rest) (pair? (cdr rest)))
134 (cadr rest)
135 0))
136 (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest)))
137 (caddr rest)
138 (string-length s))))
139 (hash (substring/shared s start end) bound))))
140
141 (define string-hash-ci
142 (lambda (s . rest)
143 (let ((bound (if (pair? rest)
144 (or (car rest)
145 871)
146 871))
147 (start (if (and (pair? rest) (pair? (cdr rest)))
148 (cadr rest)
149 0))
150 (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest)))
151 (caddr rest)
152 (string-length s))))
153 (hash (string-upcase (substring/shared s start end)) bound))))
154
155 ;;; srfi-13.scm ends here