sets
[advent18.git] / 1 / s2.icl
1 module s2
2
3 import StdEnv
4
5 import Data.Func
6 import qualified Data.Set
7 import Text
8
9 getinput f
10 # (ok, c, f) = freadc f
11 | not ok = []
12 = [c:getinput f]
13
14 split :: [Char] [Char] -> [[Char]]
15 split [] [] = []
16 split c [] = [reverse c]
17 split c ['\n':rest] = [reverse c:split [] rest]
18 split c [r:rest] = split [r:c] rest
19
20 Start w
21 # (_, io, w) = fopen "input.txt" FReadText w
22 = proc 'Data.Set'.newSet
23 $ scan (+) 0
24 $ map (toInt o toString)
25 $ flatten
26 $ repeat
27 $ split []
28 $ getinput io
29
30 proc have [x:xs]
31 | 'Data.Set'.member x have = x
32 = proc ('Data.Set'.insert x have) xs