blob: fb469ffb9ededbc509d1fbbc477072e2eb420846 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
#| Copyright (C) 2025 Peter McGoron
|
| This program is free software: you can redistribute it and/or modify it
| under the terms of the GNU General Public License as published by the
| Free Software Foundation, either version 3 of the License, or (at your
| option) any later version.
|
| This program is distributed in the hope that it will be useful, but
| WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
| General Public License for more details.
|
| You should have received a copy of the GNU General Public License along
| with this program. If not, see <https://www.gnu.org/licenses/>.
|#
(define-module (mcgoron guix srfi)
#:use-module (rnrs base)
#:use-module (guix packages)
#:use-module (guix utils)
#:use-module (gnu packages)
#:use-module (guix licenses)
#:use-module (guix git-download)
#:use-module (guix download)
#:use-module (guix build-system gnu)
#:use-module (guix build-system)
#:use-module (guix build-system copy)
#:use-module (guix build-system trivial)
#:use-module (guix build-system cmake)
#:use-module (mcgoron guix scheme-packages)
#:use-module (guix gexp))
(define srfi-1-exports
'(xcons make-list list-tabulate cons* list-copy
proper-list? circular-list? dotted-list? not-pair? null-list? list=
circular-list length+
iota
first second third fourth fifth sixth seventh eighth ninth tenth
car+cdr
take drop
take-right drop-right
take! drop-right!
split-at split-at!
last last-pair
zip unzip1 unzip2 unzip3 unzip4 unzip5
count
append! append-reverse append-reverse! concatenate concatenate!
unfold fold pair-fold reduce
unfold-right fold-right pair-fold-right reduce-right
append-map append-map! map! pair-for-each filter-map map-in-order
filter partition remove
filter! partition! remove!
find find-tail any every list-index
take-while drop-while take-while!
span break span! break!
delete delete!
alist-cons alist-copy
delete-duplicates delete-duplicates!
alist-delete alist-delete!
reverse!
lset<= lset= lset-adjoin
lset-union lset-intersection lset-difference lset-xor lset-diff+intersection
lset-union! lset-intersection! lset-difference! lset-xor! lset-diff+intersection!
map for-each member assoc))
(define srfi-1-special-forms
''(begin
(define-syntax let-optionals
(syntax-rules ()
((_ expr ((v d) ... . tail) . body)
($let-optionals (v ...) () (d ...) () f tail expr body))))
(define-syntax $let-optionals
(syntax-rules ()
((_ () (vt ...) _ (cl ...) f tail expr body)
(letrec ((f (case-lambda cl ... ((vt ... . tail) . body))))
(apply f expr)))
((_ (vrf . vr*) (vt ...) (df . dr*) (cl ...) f . tailexprbody)
($let-optionals vr* (vt ... vrf) dr* (cl ... ((vt ...) (f vt ... df))) f . tailexprbody))))
(define-syntax receive
(syntax-rules ()
((_ formals value body ...)
(let-values ((formals value)) body ...))))
(define-syntax :optional
(syntax-rules ()
((_ x y) (if (null? x) y (car x)))))
(define (for-each f l1 . l-rest)
(let loop ((lists (cons l1 l-rest)))
(receive (cars cdrs) (%cars+cdrs lists)
(if (pair? cars)
(begin
(apply f cars)
(loop cdrs))))))))
(define-public srfi-1-r7rs
(package
(name "srfi-1-r7rs")
(version "errata-7")
(source
(origin (method git-fetch)
(uri (git-reference (url "https://github.com/scheme-requests-for-implementation/srfi-1")
(commit "errata-7")))
(sha256 (base32 "18lj5y85zxs0yzkdv66qd290nwms7jy27ky1x3ba9kp6hzjia5kj"))))
(build-system copy-build-system)
(home-page "https://srfi.schemers.org/srfi-1")
(synopsis "List library (R7RS)")
(license (non-copyleft "//srfi.schemers.org/srfi-1/srfi-1.html"))
(inputs '())
(native-inputs '())
(description " R5RS Scheme has an impoverished set of list-processing utilities, which is a problem for authors of portable code. This SRFI proposes a coherent and comprehensive set of list-processing procedures; it is accompanied by a reference implementation of the spec. The reference implementation is
portable
efficient
completely open, public-domain source
")
(arguments
(list
#:imported-modules `(,@%copy-build-system-modules (mcgoron guix srfi-util))
#:phases
#~ (modify-phases %standard-phases
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(use-modules (mcgoron guix srfi-util))
(let ((lib (string-append (assoc-ref %outputs "out")
"/" #$r7rs-lib-dir
"/srfi")))
(mkdir-p lib)
(splice-files (string-append lib "/1.sld")
7
'(srfi 1)
'#$srfi-1-exports
'((scheme base) (scheme cxr) (scheme case-lambda))
'(define-syntax check-arg
(syntax-rules ()
((_ pred val caller)
(let ((tmp val))
(if (pred val)
val
(error "Bad argument" 'pred
tmp
'caller))))))
#$srfi-1-special-forms
"srfi-1-reference.scm")))))))))
(define-public srfi-1-r6rs
(package
(name "srfi-1-r6rs")
(version "errata-7")
(source
(origin (method git-fetch)
(uri (git-reference (url "https://github.com/scheme-requests-for-implementation/srfi-1")
(commit "errata-7")))
(sha256 (base32 "18lj5y85zxs0yzkdv66qd290nwms7jy27ky1x3ba9kp6hzjia5kj"))))
(build-system copy-build-system)
(home-page "https://srfi.schemers.org/srfi-1")
(synopsis "List library (R6RS)")
(license (non-copyleft "//srfi.schemers.org/srfi-1/srfi-1.html"))
(inputs '())
(native-inputs '())
(description " R5RS Scheme has an impoverished set of list-processing utilities, which is a problem for authors of portable code. This SRFI proposes a coherent and comprehensive set of list-processing procedures; it is accompanied by a reference implementation of the spec. The reference implementation is
portable
efficient
completely open, public-domain source
")
(arguments
(list
#:imported-modules `(,@%copy-build-system-modules (mcgoron guix srfi-util))
#:phases
#~ (modify-phases %standard-phases
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(use-modules (mcgoron guix srfi-util))
(let ((lib (string-append (assoc-ref %outputs "out")
"/" #$r6rs-lib-dir
"/srfi")))
(mkdir-p lib)
(splice-files (string-append lib "/srfi-1.sls")
6
'(srfi srfi-1)
'#$srfi-1-exports
'((except (rename (rnrs base) (error %error))
map
for-each)
(rnrs control)
(except (rnrs lists) remove find partition filter fold-right cons* member assoc)
(rnrs mutable-pairs) (rnrs r5rs))
'(define-syntax check-arg
(syntax-rules ()
((_ pred val caller)
(let ((tmp val))
(if (pred val)
val
(assertion-violation
'caller
"invalid argument"
val
'pred))))))
'(define (error msg . irritants)
(apply %error #f msg irritants))
#$srfi-1-special-forms
"srfi-1-reference.scm")))))))))
|