-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpr9.spl
More file actions
27 lines (22 loc) · 777 Bytes
/
Copy pathpr9.spl
File metadata and controls
27 lines (22 loc) · 777 Bytes
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
let postfix (post:set word:string):set =
(if (seteq post {})
then {}
else (cons (strapp word (head post)) (postfix (tail post) word)))
;;
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 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)))))
;;
let abset:set = {"a", "b"};;
(restrict (sort (concatenate (union arg0 arg1) abset)) maxoutput);;