Commit | Line | Data |
---|---|---|
ca003b26 MG |
1 | ;;;; srfi-13.scm --- SRFI-13 procedures for Guile |
2 | ;;;; | |
3 | ;;;; Copyright (C) 2001 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 | (define-module (srfi srfi-13)) | |
21 | ||
22 | (export | |
23 | ;;; Predicates | |
24 | ;; string? string-null? <= in the core | |
25 | string-any string-every | |
26 | ||
27 | ;;; Constructors | |
28 | ;; make-string string <= in the core | |
29 | string-tabulate | |
30 | ||
31 | ;;; List/string conversion | |
32 | string->list | |
33 | ;; list->string <= in the core | |
34 | reverse-list->string | |
35 | string-join | |
36 | ||
37 | ;;; Selection | |
38 | ;; string-length string-ref <= in the core | |
39 | string-copy | |
40 | substring/shared | |
41 | string-copy! | |
42 | string-take string-take-right | |
43 | string-drop string-drop-right | |
44 | string-pad string-pad-right | |
45 | string-trim string-trim-right | |
46 | string-trim-both | |
47 | ||
48 | ;;; Modification | |
49 | ;; string-set! <= in the core | |
50 | string-fill! | |
51 | ||
52 | ;;; Comparison | |
53 | string-compare string-compare-ci | |
54 | string= string<> | |
55 | string< string> | |
56 | string<= string>= | |
57 | string-ci= string-ci<> | |
58 | string-ci< string-ci> | |
59 | string-ci<= string-ci>= | |
fafb71de | 60 | string-hash string-hash-ci |
ca003b26 MG |
61 | |
62 | ;;; Prefixes/Suffixes | |
63 | string-prefix-length | |
64 | string-prefix-length-ci | |
65 | string-suffix-length | |
66 | string-suffix-length-ci | |
67 | string-prefix? | |
68 | string-prefix-ci? | |
69 | string-suffix? | |
70 | string-suffix-ci? | |
71 | ||
72 | ;;; Searching | |
73 | string-index string-index-right | |
74 | string-skip string-skip-right | |
75 | string-count | |
76 | string-contains string-contains-ci | |
77 | ||
78 | ;;; Alphabetic case mapping | |
79 | ||
80 | string-upcase string-upcase! | |
81 | string-downcase string-downcase! | |
82 | string-titlecase string-titlecase! | |
83 | ||
84 | ;;; Reverse/Append | |
85 | string-reverse string-reverse! | |
86 | ;; string-append <= in the core | |
87 | string-append/shared | |
88 | string-concatenate | |
8dddb4bc | 89 | string-concatenate-reverse |
ca003b26 | 90 | string-concatenate/shared |
8dddb4bc | 91 | string-concatenate-reverse/shared |
ca003b26 MG |
92 | |
93 | ;;; Fold/Unfold/Map | |
94 | string-map string-map! | |
95 | string-fold | |
96 | string-fold-right | |
97 | string-unfold | |
98 | string-unfold-right | |
99 | string-for-each | |
100 | ||
101 | ;;; Replicate/Rotate | |
102 | xsubstring string-xcopy! | |
103 | ||
104 | ;;; Miscellaneous | |
105 | string-replace | |
106 | string-tokenize | |
107 | ||
108 | ;;; Filtering/Deleting | |
109 | string-filter | |
110 | string-delete | |
111 | ) | |
112 | ||
94451729 | 113 | (dynamic-call "scm_init_srfi_13" (dynamic-link "libguile-srfi-srfi-13-14")) |
ca003b26 MG |
114 | |
115 | (define string-hash | |
116 | (lambda (s . rest) | |
117 | (let ((bound (if (pair? rest) | |
118 | (or (car rest) | |
119 | 871) | |
120 | 871)) | |
121 | (start (if (and (pair? rest) (pair? (cdr rest))) | |
122 | (cadr rest) | |
123 | 0)) | |
124 | (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest))) | |
125 | (caddr rest) | |
126 | (string-length s)))) | |
127 | (hash (substring/shared s start end) bound)))) | |
128 | ||
129 | (define string-hash-ci | |
130 | (lambda (s . rest) | |
131 | (let ((bound (if (pair? rest) | |
132 | (or (car rest) | |
133 | 871) | |
134 | 871)) | |
135 | (start (if (and (pair? rest) (pair? (cdr rest))) | |
136 | (cadr rest) | |
137 | 0)) | |
138 | (end (if (and (pair? rest) (pair? (cdr rest)) (pair? (cddr rest))) | |
139 | (caddr rest) | |
140 | (string-length s)))) | |
141 | (hash (string-upcase (substring/shared s start end)) bound)))) |