-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpr10.spl
More file actions
52 lines (45 loc) · 1.72 KB
/
pr10.spl
File metadata and controls
52 lines (45 loc) · 1.72 KB
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
let asterate (max:int appendTo:string ast:string):set =
let help (max:int as:string):set =
(if (== max 0) then {}
else (cons (strapp appendTo as) (help (- max 1) (strapp as ast))))
in (help max ":")
;;
let union (first:set second:set):set =
(if (seteq first {}) then (if (seteq second {}) then {} else (union second {}))
else (cons (head first) (union (tail first) second)))
;;
let astGen (max:int ast:string):set =
let help (max:int as:string):set =
(if (== max 0) then {}
else (cons as (help (- max 1) (strapp as ast))))
in (help max ":")
;;
let postfix (post:set word:string):set =
(if (seteq post {})
then {}
else (cons (strapp word (head post)) (postfix (tail post) word)))
;;
let concatenate(lang:set post:set):set =
(if (seteq lang {}) then {} else
(union (postfix post (head lang))
(concatenate (tail lang) post)))
;;
let restrict (ins:set num:int):set =
(if (== num 0) then {}
else (if (seteq ins {}) then {}
else (cons (head ins) (restrict (tail ins) (- num 1)))))
;;
(restrict (sort (union (if (seteq arg0 {})
then {}
else (asterate maxoutput (head (sort arg0)) "a"))
(if (seteq arg1 {})
then {}
else (asterate maxoutput (head (sort arg1)) "b"))))
maxoutput);;
(restrict (sort (union (if (seteq arg0 {})
then {}
else (concatenate arg0 (astGen maxoutput "a")))
(if (seteq arg1 {})
then {}
else (concatenate arg1 (astGen maxoutput "b")))))
maxoutput);;