nendo 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,383 @@
1
+ ;;-*- mode: nendo; syntax: scheme -*-;;
2
+ ;;
3
+ ;; util-combinations-test.nnd - test suite for util.combinations
4
+ ;;
5
+ ;; Copyright (c) 2000-2010 Shiro Kawai <shiro@acm.org>
6
+ ;;
7
+ ;; Redistribution and use in source and binary forms, with or without
8
+ ;; modification, are permitted provided that the following conditions
9
+ ;; are met:
10
+ ;;
11
+ ;; 1. Redistributions of source code must retain the above copyright
12
+ ;; notice, this list of conditions and the following disclaimer.
13
+ ;;
14
+ ;; 2. Redistributions in binary form must reproduce the above copyright
15
+ ;; notice, this list of conditions and the following disclaimer in the
16
+ ;; documentation and/or other materials provided with the distribution.
17
+ ;;
18
+ ;; 3. Neither the name of the authors nor the names of its contributors
19
+ ;; may be used to endorse or promote products derived from this
20
+ ;; software without specific prior written permission.
21
+ ;;
22
+ ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
+ ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
+ ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
+ ;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
+ ;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
+ ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
28
+ ;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29
+ ;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30
+ ;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31
+ ;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
+ ;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+
34
+
35
+ (use nendo.test)
36
+ (use util.match)
37
+ (test-start "util.combination")
38
+
39
+ ;;===================================================================
40
+ ;;-------------------------------------------------------------------
41
+
42
+
43
+ (test-section "util.combinations")
44
+ (use util.combinations)
45
+
46
+ (test* "permutations (boundary)" '(())
47
+ (permutations '()))
48
+ (test* "permutations (boundary)" '((a))
49
+ (permutations '(a)))
50
+ (test* "permutations" '((a b) (b a))
51
+ (permutations '(a b)))
52
+ (test* "permutations" '((a a) (a a))
53
+ (permutations '(a a)))
54
+ (test* "permutations" '((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
55
+ (permutations '(a b c)))
56
+ (test* "permutations" '((a b c d) (a b d c) (a c b d) (a c d b)
57
+ (a d b c) (a d c b) (b a c d) (b a d c)
58
+ (b c a d) (b c d a) (b d a c) (b d c a)
59
+ (c a b d) (c a d b) (c b a d) (c b d a)
60
+ (c d a b) (c d b a) (d a b c) (d a c b)
61
+ (d b a c) (d b c a) (d c a b) (d c b a))
62
+ (permutations '(a b c d)))
63
+
64
+ (test* "permutations* (boundary)" '(())
65
+ (permutations* '()))
66
+ (test* "permutations* (boundary)" '((a))
67
+ (permutations* '(a)))
68
+ (test* "permutations*" '((a b) (b a))
69
+ (permutations* '(a b)))
70
+ (test* "permutations*" '((a a))
71
+ (permutations* '(a a)))
72
+ (test* "permutations*" '((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
73
+ (permutations* '(a b c)))
74
+ (test* "permutations*" '((a a b) (a b a) (b a a))
75
+ (permutations* '(a a b)))
76
+ (test* "permutations*" '((a b a) (a a b) (b a a))
77
+ (permutations* '(a b a)))
78
+ (test* "permutations*" '((b a a) (a b a) (a a b))
79
+ (permutations* '(b a a)))
80
+ (test* "permutations*" '((a a a))
81
+ (permutations* '(a a a)))
82
+ (test* "permutations*" '((a b c d) (a b d c) (a c b d) (a c d b)
83
+ (a d b c) (a d c b) (b a c d) (b a d c)
84
+ (b c a d) (b c d a) (b d a c) (b d c a)
85
+ (c a b d) (c a d b) (c b a d) (c b d a)
86
+ (c d a b) (c d b a) (d a b c) (d a c b)
87
+ (d b a c) (d b c a) (d c a b) (d c b a))
88
+ (permutations* '(a b c d)))
89
+ (test* "permutations*" '((a a b c) (a a c b) (a b a c) (a b c a)
90
+ (a c a b) (a c b a) (b a a c) (b a c a)
91
+ (b c a a) (c a a b) (c a b a) (c b a a))
92
+ (permutations* '(a a b c)))
93
+ (test* "permutations*" '((a b a c) (a b c a) (a a b c) (a a c b)
94
+ (a c b a) (a c a b) (b a a c) (b a c a)
95
+ (b c a a) (c a b a) (c a a b) (c b a a))
96
+ (permutations* '(a b a c)))
97
+ (test* "permutations*" '((a b c a) (a b a c) (a c b a) (a c a b)
98
+ (a a b c) (a a c b) (b a c a) (b a a c)
99
+ (b c a a) (c a b a) (c a a b) (c b a a))
100
+ (permutations* '(a b c a)))
101
+ (test* "permutations*" '((a b a b) (a b b a) (a a b b)
102
+ (b a a b) (b a b a) (b b a a))
103
+ (permutations* '(a b a b)))
104
+ (test* "permutations*" '((a a a b) (a a b a) (a b a a) (b a a a))
105
+ (permutations* '(a a a b)))
106
+ (test* "permutations*" '((a b a a) (a a b a) (a a a b) (b a a a))
107
+ (permutations* '(a b a a)))
108
+ (test* "permutations*" '((a a a a))
109
+ (permutations* '(a a a a)))
110
+
111
+ (test* "permutations*" '(("a" "b" "b" "a") ("a" "b" "a" "b") ("a" "a" "b" "b")
112
+ ("b" "a" "b" "a") ("b" "a" "a" "b") ("b" "b" "a" "a"))
113
+ (permutations* '("a" "b" "b" "a") string=?))
114
+
115
+ (test* "permutations-for-each"
116
+ '()
117
+ (let1 r '()
118
+ (permutations-for-each (lambda (p) (push! r p)) '())
119
+ (reverse r)))
120
+ (test* "permutations-for-each"
121
+ '((a))
122
+ (let1 r '()
123
+ (permutations-for-each (lambda (p) (push! r p)) '(a))
124
+ (reverse r)))
125
+ (test* "permutations-for-each"
126
+ '((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
127
+ (let1 r '()
128
+ (permutations-for-each (lambda (p) (push! r p)) '(a b c))
129
+ (reverse r)))
130
+ (test* "permutations-for-each"
131
+ '((a b c d) (a b d c) (a c b d) (a c d b)
132
+ (a d b c) (a d c b) (b a c d) (b a d c)
133
+ (b c a d) (b c d a) (b d a c) (b d c a)
134
+ (c a b d) (c a d b) (c b a d) (c b d a)
135
+ (c d a b) (c d b a) (d a b c) (d a c b)
136
+ (d b a c) (d b c a) (d c a b) (d c b a))
137
+ (let1 r '()
138
+ (permutations-for-each (lambda (p) (push! r p)) '(a b c d))
139
+ (reverse r)))
140
+ (test* "permutations-for-each"
141
+ (let* ((set '(a b c d e))
142
+ (all-patterns
143
+ (append-map
144
+ (lambda (v1)
145
+ (append-map
146
+ (lambda (v2)
147
+ (append-map
148
+ (lambda (v3)
149
+ (append-map
150
+ (lambda (v4)
151
+ (map
152
+ (lambda (v5)
153
+ (list v1 v2 v3 v4 v5))
154
+ set))
155
+ set))
156
+ set))
157
+ set))
158
+ set)))
159
+ (filter
160
+ (lambda (x)
161
+ (eq? (length x)
162
+ (length (delete-duplicates x))))
163
+ all-patterns))
164
+ (let1 r '()
165
+ (permutations-for-each (lambda (p) (push! r p)) '(a b c d e))
166
+ (reverse r)))
167
+ (test* "permutations*-for-each"
168
+ '()
169
+ (let1 r '()
170
+ (permutations*-for-each (lambda (p) (push! r p)) '())
171
+ (reverse r)))
172
+ (test* "permutations*-for-each"
173
+ '((a))
174
+ (let1 r '()
175
+ (permutations*-for-each (lambda (p) (push! r p)) '(a))
176
+ (reverse r)))
177
+ (test* "permutations*-for-each"
178
+ '((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))
179
+ (let1 r '()
180
+ (permutations*-for-each (lambda (p) (push! r p)) '(a b c))
181
+ (reverse r)))
182
+ (test* "permutations*-for-each"
183
+ '((a a b) (a b a) (b a a))
184
+ (let1 r '()
185
+ (permutations*-for-each (lambda (p) (push! r p)) '(a a b))
186
+ (reverse r)))
187
+ (test* "permutations*-for-each"
188
+ '((a a a))
189
+ (let1 r '()
190
+ (permutations*-for-each (lambda (p) (push! r p)) '(a a a))
191
+ (reverse r)))
192
+ (test* "permutations*-for-each"
193
+ '(("a" "a" "b") ("a" "b" "a") ("b" "a" "a"))
194
+ (let1 r '()
195
+ (permutations*-for-each (lambda (p) (push! r p)) '("a" "a" "b")
196
+ string=?)
197
+ (reverse r)))
198
+
199
+ (test* "combinations" '(())
200
+ (combinations '() 0))
201
+ (test* "combinations" '((a))
202
+ (combinations '(a) 1))
203
+ (test* "combinations" '((a) (b) (c) (d))
204
+ (combinations '(a b c d) 1))
205
+ (test* "combinations" '((a b) (a c) (b c))
206
+ (combinations '(a b c) 2))
207
+ (test* "combinations" '((a b c))
208
+ (combinations '(a b c) 3))
209
+ (test* "combinations" '((a b c) (a b d) (a c d) (b c d))
210
+ (combinations '(a b c d) 3))
211
+
212
+ (test* "combinations*" '(())
213
+ (combinations* '() 0))
214
+ (test* "combinations*" '((a))
215
+ (combinations* '(a) 1))
216
+ (test* "combinations*" '((a) (b) (c) (d))
217
+ (combinations* '(a b c d) 1))
218
+ (test* "combinations*" '((a b) (a c) (b c))
219
+ (combinations* '(a b c) 2))
220
+ (test* "combinations*" '((a b c))
221
+ (combinations* '(a b c) 3))
222
+ (test* "combinations*" '((a b c) (a b d) (a c d) (b c d))
223
+ (combinations* '(a b c d) 3))
224
+ (test* "combinations*" '((a) (b))
225
+ (combinations* '(a a b) 1))
226
+ (test* "combinations*" '((a a) (a b))
227
+ (combinations* '(a a b) 2))
228
+ (test* "combinations*" '((a a b))
229
+ (combinations* '(a a b) 3))
230
+ (test* "combinations*" '((a b) (a a))
231
+ (combinations* '(a b a a) 2))
232
+ (test* "combinations*" '((a b a) (a a a))
233
+ (combinations* '(a b a a) 3))
234
+ (test* "combinations*" '((a b b) (a b a))
235
+ (combinations* '(a b b a) 3))
236
+ (test* "combinations*" '(("a" "b" "b") ("a" "b" "a"))
237
+ (combinations* '("a" "b" "b" "a") 3 string=?))
238
+
239
+ (test* "combinations-for-each" '(())
240
+ (let1 r '()
241
+ (combinations-for-each (lambda (c) (push! r c)) '() 0)
242
+ (reverse! r)))
243
+ (test* "combinations-for-each" '((a))
244
+ (let1 r '()
245
+ (combinations-for-each (lambda (c) (push! r c)) '(a) 1)
246
+ (reverse! r)))
247
+ (test* "combinations-for-each" '((a) (b) (c) (d))
248
+ (let1 r '()
249
+ (combinations-for-each (lambda (c) (push! r c)) '(a b c d) 1)
250
+ (reverse! r)))
251
+ (test* "combinations-for-each" '((a b) (a c) (b c))
252
+ (let1 r '()
253
+ (combinations-for-each (lambda (c) (push! r c)) '(a b c) 2)
254
+ (reverse! r)))
255
+ (test* "combinations-for-each" '((a b c))
256
+ (let1 r '()
257
+ (combinations-for-each (lambda (c) (push! r c)) '(a b c) 3)
258
+ (reverse! r)))
259
+ (test* "combinations-for-each" '((a b c) (a b d) (a c d) (b c d))
260
+ (let1 r '()
261
+ (combinations-for-each (lambda (c) (push! r c)) '(a b c d) 3)
262
+ (reverse! r)))
263
+
264
+ (test* "combinations*-for-each" '(())
265
+ (let1 r '()
266
+ (combinations*-for-each (lambda (c) (push! r c)) '() 0)
267
+ (reverse! r)))
268
+ (test* "combinations*-for-each" '((a))
269
+ (let1 r '()
270
+ (combinations*-for-each (lambda (c) (push! r c)) '(a) 1)
271
+ (reverse! r)))
272
+ (test* "combinations*-for-each" '((a) (b) (c) (d))
273
+ (let1 r '()
274
+ (combinations*-for-each (lambda (c) (push! r c)) '(a b c d) 1)
275
+ (reverse! r)))
276
+ (test* "combinations*-for-each" '((a b) (a c) (b c))
277
+ (let1 r '()
278
+ (combinations*-for-each (lambda (c) (push! r c)) '(a b c) 2)
279
+ (reverse! r)))
280
+ (test* "combinations*-for-each" '((a b c))
281
+ (let1 r '()
282
+ (combinations*-for-each (lambda (c) (push! r c)) '(a b c) 3)
283
+ (reverse! r)))
284
+ (test* "combinations*-for-each" '((a b c) (a b d) (a c d) (b c d))
285
+ (let1 r '()
286
+ (combinations*-for-each (lambda (c) (push! r c)) '(a b c d) 3)
287
+ (reverse! r)))
288
+ (test* "combinations*-for-each" '((a) (b))
289
+ (let1 r '()
290
+ (combinations*-for-each (lambda (c) (push! r c)) '(a a b) 1)
291
+ (reverse! r)))
292
+ (test* "combinations*-for-each" '((a a) (a b))
293
+ (let1 r '()
294
+ (combinations*-for-each (lambda (c) (push! r c)) '(a a b) 2)
295
+ (reverse! r)))
296
+ (test* "combinations*-for-each" '((a a b))
297
+ (let1 r '()
298
+ (combinations*-for-each (lambda (c) (push! r c)) '(a a b) 3)
299
+ (reverse! r)))
300
+ (test* "combinations*-for-each" '((a b) (a a))
301
+ (let1 r '()
302
+ (combinations*-for-each (lambda (c) (push! r c)) '(a b a a) 2)
303
+ (reverse! r)))
304
+ (test* "combinations*-for-each" '((a b a) (a a a))
305
+ (let1 r '()
306
+ (combinations*-for-each (lambda (c) (push! r c)) '(a b a a) 3)
307
+ (reverse! r)))
308
+ (test* "combinations*-for-each" '((a b b) (a b a))
309
+ (let1 r '()
310
+ (combinations*-for-each (lambda (c) (push! r c)) '(a b b a) 3)
311
+ (reverse! r)))
312
+ (test* "combinations*-for-each" '(("a" "b" "b") ("a" "b" "a"))
313
+ (let1 r '()
314
+ (combinations*-for-each (lambda (c) (push! r c)) '("a" "b" "b" "a") 3
315
+ string=?)
316
+ (reverse! r)))
317
+
318
+ (test* "power-set-binary" '(())
319
+ (power-set-binary '()))
320
+ (test* "power-set-binary" '(() (a))
321
+ (power-set-binary '(a)))
322
+ (test* "power-set-binary" '(() (c) (b) (b c) (a) (a c) (a b) (a b c))
323
+ (power-set-binary '(a b c)))
324
+
325
+ (test* "power-set" '(())
326
+ (power-set '()))
327
+ (test* "power-set" '(() (a))
328
+ (power-set '(a)))
329
+ (test* "power-set" '(() (a) (b) (c) (a b) (a c) (b c) (a b c))
330
+ (power-set '(a b c)))
331
+
332
+ (test* "power-set*" '(())
333
+ (power-set* '()))
334
+ (test* "power-set*" '(() (a))
335
+ (power-set* '(a)))
336
+ (test* "power-set*" '(() (a) (b) (a a) (a b) (a a b))
337
+ (power-set* '(a a b)))
338
+ (test* "power-set*" '(() ("a") ("b") ("a" "a") ("a" "b") ("a" "a" "b"))
339
+ (power-set* '("a" "a" "b") string=?))
340
+
341
+ (test* "power-set-for-each" '(())
342
+ (let1 r '()
343
+ (power-set-for-each (lambda (s) (push! r s)) '())
344
+ (reverse! r)))
345
+ (test* "power-set-for-each" '(() (a))
346
+ (let1 r '()
347
+ (power-set-for-each (lambda (s) (push! r s)) '(a))
348
+ (reverse! r)))
349
+ (test* "power-set-for-each" '(() (a) (b) (c) (a b) (a c) (b c) (a b c))
350
+ (let1 r '()
351
+ (power-set-for-each (lambda (s) (push! r s)) '(a b c))
352
+ (reverse! r)))
353
+
354
+ (test* "power-set*-for-each" '(())
355
+ (let1 r '()
356
+ (power-set*-for-each (lambda (s) (push! r s)) '())
357
+ (reverse! r)))
358
+ (test* "power-set*-for-each" '(() (a))
359
+ (let1 r '()
360
+ (power-set*-for-each (lambda (s) (push! r s)) '(a))
361
+ (reverse! r)))
362
+ (test* "power-set*-for-each" '(() (a) (b) (a a) (a b) (a a b))
363
+ (let1 r '()
364
+ (power-set*-for-each (lambda (s) (push! r s)) '(a a b))
365
+ (reverse! r)))
366
+ (test* "power-set*-for-each" '(() ("a") ("b") ("a" "a") ("a" "b") ("a" "a" "b"))
367
+ (let1 r '()
368
+ (power-set*-for-each (lambda (s) (push! r s)) '("a" "a" "b")
369
+ string=?)
370
+ (reverse! r)))
371
+
372
+ (test* "cartesian-product" '((a 0) (a 1) (b 0) (b 1) (c 0) (c 1))
373
+ (cartesian-product '((a b c) (0 1))))
374
+ (test* "cartesian-product" '((a 0 0) (a 0 1) (a 1 0) (a 1 1)
375
+ (b 0 0) (b 0 1) (b 1 0) (b 1 1))
376
+ (cartesian-product '((a b) (0 1) (0 1))))
377
+ (test* "cartesian-product-right" '((a 0) (b 0) (c 0) (a 1) (b 1) (c 1))
378
+ (cartesian-product-right '((a b c) (0 1))))
379
+
380
+
381
+
382
+ ;;===================================================================
383
+ (test-end)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 0
9
- version: 0.5.0
8
+ - 1
9
+ version: 0.5.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kiyoka Nishiyama
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-04-25 00:00:00 +09:00
17
+ date: 2011-06-24 00:00:00 +09:00
18
18
  default_executable: nendo
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -60,7 +60,6 @@ files:
60
60
  - example/fizzbuzz1.nnd
61
61
  - example/html-lite-sample.nnd
62
62
  - example/nqueen.nnd
63
- - example/scratch.nnd
64
63
  - example/twitterTL.nnd
65
64
  - lib/debug/syslog.nnd
66
65
  - lib/debug/syslog.nndc
@@ -81,9 +80,14 @@ files:
81
80
  - lib/text/html-lite.nndc
82
81
  - lib/text/tree.nnd
83
82
  - lib/text/tree.nndc
83
+ - lib/util/combinations.nnd
84
+ - lib/util/combinations.nndc
84
85
  - lib/util/list.nnd
85
86
  - lib/util/list.nndc
87
+ - lib/util/match.nnd
88
+ - lib/util/match.nndc
86
89
  - test/json-test.nnd
90
+ - test/match-test.nnd
87
91
  - test/nendo-util-test.nnd
88
92
  - test/nendo_spec.rb
89
93
  - test/srfi-1-test.nnd
@@ -91,6 +95,7 @@ files:
91
95
  - test/srfi-26-test.nnd
92
96
  - test/syntax_spec.rb
93
97
  - test/textlib-test.nnd
98
+ - test/util-combinations-test.nnd
94
99
  - test/util-list-test.nnd
95
100
  - README
96
101
  has_rdoc: true
data/example/scratch.nnd DELETED
@@ -1,119 +0,0 @@
1
- ;;-*- mode: nendo; syntax: scheme -*-;;
2
- ;; -----------------
3
- (enable-idebug)
4
- (disable-idebug)
5
- (exit)
6
-
7
- (debug-print-length)
8
- (debug-print-length 2000)
9
-
10
- (error "Error: (error) func test 1")
11
- (error "Error: (error) func test 1" '(r a i s e))
12
-
13
-
14
- (define (generic-member cmp obj lst)
15
- (cond
16
- ((null? lst) #f)
17
- ((not (pair? lst)) #f)
18
- ((cmp obj (car lst)) lst)
19
- (else (generic-member cmp obj (cdr lst)))))
20
-
21
-
22
- (memq 'b '(a b c d))
23
- (memq 'a '(a b c d . e))
24
-
25
-
26
-
27
- ;; :optional feature from Gauche-0.9.1 .
28
-
29
- (define %expand-define-form-lambda
30
- (lambda (arg body-list)
31
- ;; (define (func arg...) body)
32
- (if (pair? (cdr arg))
33
- (if (pair? (car (cdr arg)))
34
- (error "Error: define syntax error.")))
35
- (cons 'define
36
- (list (car arg)
37
- (%transform-optional-arguments (cdr arg) body-list)))))
38
-
39
-
40
- (define (%transform-optional-arguments arg body-list)
41
- (if-let1 rest-of-opts (memq :optional arg)
42
- (let([opts '()]
43
- [rest-of-opts (cdr rest-of-opts)]
44
- [_rest (gensym)])
45
- ;; arguemnt form check
46
- (for-each
47
- (lambda (x)
48
- (let1 syntax-is-ok (if (pair? x)
49
- (= 2 (length x))
50
- #f)
51
- (unless syntax-is-ok
52
- (error "Error: :optional format is illegal ... " arg))))
53
- rest-of-opts)
54
- (let loop ((arg arg))
55
- (if (eq? :optional (car arg))
56
- arg
57
- (begin
58
- (set! opts (cons (car arg) opts))
59
- (loop (cdr arg)))))
60
- (let1 new-arg (apply list* (append (reverse opts) (list _rest)))
61
- (list 'lambda
62
- new-arg
63
- `(let
64
- ,rest-of-opts
65
- ,@(map
66
- (lambda (k n)
67
- `(when (< ,n (length ,_rest))
68
- (set! ,(car k) (nth ,n ,_rest))))
69
- rest-of-opts
70
- (range (length rest-of-opts)))
71
- ,@body-list))))
72
- `(lambda ,arg ,@body-list)))
73
-
74
-
75
- (%transform-optional-arguments '(arg1 arg2)
76
- '((begin 1 2)))
77
- (pretty-print
78
- (%transform-optional-arguments '(arg1 arg2 :optional (arg3 #f))
79
- '((begin 1 2))))
80
-
81
- (pretty-print
82
- (%transform-optional-arguments '(arg1 arg2 :optional (arg3 #f) (arg4 #t))
83
- '((begin 1 2))))
84
-
85
- (pretty-print
86
- (%transform-optional-arguments '(arg1 arg2 :optional illegal-arg (arg3 #f) (arg4 #t))
87
- '((begin 1 2))))
88
- (pretty-print
89
- (%transform-optional-arguments '(arg1 arg2 :optional (arg3 #f) (arg4 #t) illegal-arg)
90
- '((begin 1 2))))
91
- (pretty-print
92
- (%transform-optional-arguments '(arg1 arg2 :optional (arg3 #f) illegal-arg (arg4 #t))
93
- '((begin 1 2))))
94
-
95
- (pretty-print
96
- (%transform-optional-arguments '(arg1 arg2 :optional (arg3 #f #f))
97
- '((begin 1 2))))
98
-
99
-
100
- (macroexpand
101
- '(define (func arg1 arg2)
102
- (begin
103
- 1
104
- 2)))
105
-
106
- (pretty-print
107
- (macroexpand
108
- '(define (func arg1 arg2 :optional (arg3 #t))
109
- (print "1")
110
- (print "2"))))
111
-
112
- (define (func arg1 arg2 :optional (arg3 #t))
113
- (printf "[%d]" arg1)(newline)
114
- (printf "[%d]" arg2)(newline)
115
- (printf "[%s]" arg3)(newline))
116
-
117
- (func 1 2 'a)
118
-
119
-