-
Notifications
You must be signed in to change notification settings - Fork 0
/
drop-last.rkt
51 lines (42 loc) · 972 Bytes
/
drop-last.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
48
49
50
51
#lang pie
(claim base-drop-last
(Pi ((E U))
(-> (Vec E (add1 zero))
(Vec E zero))))
(define base-drop-last
(lambda (E)
(lambda (es)
vecnil)))
(claim mot-drop-last
(-> U Nat
U))
(define mot-drop-last
(lambda (E)
(lambda (k)
(-> (Vec E (add1 k))
(Vec E k)))))
(claim step-drop-last
(Pi ((E U)
(l-1 Nat))
(-> (mot-drop-last E l-1)
(mot-drop-last E (add1 l-1)))))
(define step-drop-last
(lambda (E l)
(lambda (f-1)
(lambda (es)
(vec:: (head es) (f-1 (tail es)))))))
(claim drop-last
(Pi ((E U)
(k Nat))
(-> (Vec E (add1 k))
(Vec E k))))
(define drop-last
(lambda (E l)
(lambda (es)
((ind-Nat
l
(mot-drop-last E)
(base-drop-last E)
(step-drop-last E))
es))))
(drop-last Atom 2 (vec:: 'a (vec:: 'b (vec:: 'c vecnil))))