-
Notifications
You must be signed in to change notification settings - Fork 0
/
ybot_abstraction.xtm
74 lines (48 loc) · 1.41 KB
/
ybot_abstraction.xtm
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
71
72
73
74
(sys:load-preload-check 'ybot_abstraction)
(define *xtmlib-ybot_abstraction-loaded* #f)
(impc:aot:suppress-aot-do
(sys:load "libs/contrib/ybot/ybot_parser_xtlang.xtm"))
(impc:aot:insert-forms
(sys:load "libs/contrib/ybot/ybot_parser_xtlang.xtm" 'quiet))
(define *xtmlib-ybot_abstraction-loaded* #t)
(bind-type List <!a,List*>)
(bind-type Tree <!a,List{Tree*}*>)
(bind-type TT <CC,TT*>)
(bind-type CC <float,TT{CC*}*>)
;; Formulae
(bind-func pair:[<!a,!b>*,!a,!b]*
(lambda (x y)
(let ((output:<!a,!b>* (alloc)))
(tfill! output x y)
output)))
(bind-macro (induct . args)
(let ((loop
(lambda (input output)
(cond
((not (null? input))
(pair (first input) (loop (second input) output)
(bind-func print:[void,Pair*]*
(lambda (p)
(if (null? p)
(begin (printout "<>") void)
(begin (printout "<" (tref p 0) "," (tref p 1) ">")
void))))
(bind-func first:[!a,Pair{!a,!b}*]*
(lambda (a)
(tref a 0)))
(bind-func second:[!b,Pair{!a,!b}*]*
(lambda (a)
(tref a 1)))
;; Mutually recursive
(bind-func MIN:[!a,!a,!a]*
(lambda (a b)
(if (< a b) a b)))
(bind-func cons:[!a,!b,!a]*)
(bind-type YTree <i64,List{YTree{i64}*}*>)
(bind-func test-tree
(lambda ()
(let ((yt:YTree* (YTree 3 null))
(pt:YTree* (YTree 1 (list yt))))
1)))
(bind-func fill_in_the_blanks:[String*,String*]
(lambda ()))