-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpr6.spl
More file actions
25 lines (20 loc) · 676 Bytes
/
pr6.spl
File metadata and controls
25 lines (20 loc) · 676 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
let postfixwithA:string = "a";;
let map (s:set f:string->string):set =
(if (seteq s {}) then {}
else (cons (f (head s)) (map (tail s) f)))
;;
let help (str:string):string =
(strapp str postfixwithA)
;;
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 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 setsUnion:set = (restrict (sort (union arg0 arg1)) maxoutput) in
(map setsUnion help);;