(Hash Table Reference): Wrote a new entry
[bpt/guile.git] / srfi / srfi-13.scm
CommitLineData
6be07c52
TTN
1;;; srfi-13.scm --- String Library
2
d57da08b 3;; Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
6be07c52 4;;
73be1d9e
MV
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,
6be07c52
TTN
11;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
73be1d9e
MV
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
0706ae06
TTN
18
19;;; Commentary:
20
21;; This module is fully documented in the Guile Reference Manual.
22
23;;; Code:
ca003b26 24
d57da08b
MD
25(define-module (srfi srfi-13)
26 :export (
ca003b26
MG
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
d57da08b 36 ;; string->list extended
ca003b26
MG
37 ;; list->string <= in the core
38 reverse-list->string
39 string-join
40
41;;; Selection
42 ;; string-length string-ref <= in the core
d57da08b 43 ;; string-copy extended
ca003b26
MG
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
d57da08b 54 ;; string-fill! extended
ca003b26
MG
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>=
fafb71de 64 string-hash string-hash-ci
ca003b26
MG
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
d57da08b
MD
77 ;; string-index extended
78 string-index-right
ca003b26
MG
79 string-skip string-skip-right
80 string-count
81 string-contains string-contains-ci
82
83;;; Alphabetic case mapping
84
d57da08b
MD
85 ;; string-upcase string-upcase! extended
86 ;; string-downcase string-downcase! extended
ca003b26
MG
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
8dddb4bc 94 string-concatenate-reverse
ca003b26 95 string-concatenate/shared
8dddb4bc 96 string-concatenate-reverse/shared
ca003b26
MG
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
4cf75288 105 string-for-each-index
ca003b26
MG
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 )
d57da08b
MD
118 :replace (string->list string-copy string-fill!
119 string-upcase! string-upcase string-downcase! string-downcase
120 string-index)
121 )
ca003b26 122
1b2f40b9
MG
123(cond-expand-provide (current-module) '(srfi-13))
124
dd22a80a 125(load-extension "libguile-srfi-srfi-13-14" "scm_init_srfi_13")
ca003b26
MG
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))))
1b2f40b9 154
6be07c52 155;;; srfi-13.scm ends here