-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7.txt
More file actions
42 lines (37 loc) · 926 Bytes
/
7.txt
File metadata and controls
42 lines (37 loc) · 926 Bytes
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
#lang racket
(define (rot-right! v)
(let loop ((i (- (vector-length v) 1))(last (vector-ref v (- (vector-length v) 1))))
(if (= i 0)
(begin
(vector-set! v i last)
v
)
(begin
(vector-set! v i (vector-ref v (- i 1)))
(loop (- i 1) last)
)
)
)
)
(define v (vector 1 2 3 4 5 6 7 8 9))
(rot-right! v)
(define-syntax macro-rot-right!
(syntax-rules()
((_ v)
(let loop ((i (- (vector-length v) 1))(last (vector-ref v (- (vector-length v) 1))))
(if (= i 0)
(begin
(vector-set! v i last)
v
)
(begin
(vector-set! v i (vector-ref v (- i 1)))
(loop (- i 1) last)
)
)
)
)
)
)
(macro-rot-right! v)
Так как можно реализовать функцию, то необходимости в макросе нет