-
Notifications
You must be signed in to change notification settings - Fork 0
/
concat.rkt
47 lines (38 loc) · 893 Bytes
/
concat.rkt
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
#lang pie
(claim step-append
(Pi ((E U))
(-> E (List E) (List E)
(List E))))
(define step-append
(lambda (E)
(lambda (e es appendes)
(:: e appendes))))
(claim snoc
(Pi ((E U))
(-> (List E) E
(List E))))
(define snoc
(lambda (E)
(lambda (start e)
(rec-List start
(:: e nil)
(step-append E)))))
(claim step-concat
(Pi ((E U))
(-> E (List E) (List E)
(List E))))
(define step-concat
(lambda (E)
(lambda (e es appendes)
(snoc E appendes e))))
(claim concat
(Pi ((E U))
(-> (List E) (List E)
(List E))))
(define concat
(lambda (E)
(lambda (start end)
(rec-List end
start
(step-concat E)))))
(concat Atom (:: 'a (:: 'b nil)) (:: 'c (:: 'd nil)))