blob: 919f34ccdfb9436a3fa984990a7a2f57b12a4075 (
plain)
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
|
(load "../common")
(defstruct counter-iter-fast ()
cur-val
step
limit
(:method iter-item (me)
me.cur-val)
(:method iter-step (me)
(inc me.cur-val me.step)
(if (< me.cur-val me.limit) me)))
(defstruct counter-fast ()
init
step
limit
(:method iter-begin (me)
(if (< me.init me.limit)
(new counter-iter-fast
cur-val me.init
step me.step
limit me.limit))))
(defstruct counter-iter-canon ()
cur-val
step
limit
(:method iter-item (me)
me.cur-val)
(:method iter-more (me)
(< me.cur-val me.limit))
(:method iter-step (me)
(inc me.cur-val me.step)
me))
(defstruct counter-canon ()
init
step
limit
(:method iter-begin (me)
(new counter-iter-canon
cur-val me.init
step me.step
limit me.limit)))
(test (list-seq (new counter-canon init 0 step 2 limit 10))
(0 2 4 6 8))
(test (list-seq (new counter-fast init 0 step 2 limit 10))
(0 2 4 6 8))
(test (list-seq (new counter-canon init 0 step 1 limit 0))
nil)
(test (list-seq (new counter-fast init 0 step 1 limit 0))
nil)
|