-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.scm
70 lines (69 loc) · 1.39 KB
/
utils.scm
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
(define (value-at arr pos destination-pos)
(if (null? arr)
-1
(if (eq? pos destination-pos)
(begin
(display (car arr))
(car arr)
)
(value-at (cdr arr) (+ pos 1) destination-pos)
)
)
)
(define (display-with-types-rec l first)
(if first
(if (pair? l)
(display "(")
)
)
(if (null? l)
(display ") ")
(if (number? l)
(begin
(if first
(display "")
(display " ")
)
(display l)
(display "")
)
(if (string? l)
(begin
(if first
(display "\"")
(display " \"")
)
(display l)
(display "\"")
)
(if (pair? (car l))
(begin
(display-with-types-rec (car l) #t)
(display-with-types-rec (cdr l) #f)
)
(if (pair? l)
(begin
(display-with-types-rec (car l) first)
(display-with-types-rec (cdr l) #f)
)
)
)
)
)
)
)
(define (display-with-types l)
(if (boolean? l)
(if l
(display "true")
(display "false")
)
(display-with-types-rec l #t)
)
)
(define (delete-first item arr)
(cond
((null? arr) '())
((equal? (car arr) item) (cdr arr))
(else (cons (car arr) (delete-first item (cdr arr))))
))