|
1 |
| -import Prelude hiding ((+), (-), (*)) |
| 1 | +import System.Environment (getArgs) |
| 2 | +import App (app, help) |
2 | 3 |
|
3 |
| -import Autotool.Data.RelOp ( (&), (+), (-), (*) ) |
4 |
| -import Autotool.Data.LazyTree (showTreeFn, showTree, Tree(Node), Op(Op0) ) |
5 |
| -import Autotool.Solver.Relations (solve) |
6 |
| -import Autotool.Parser.Relation (parseIntRelation) |
7 |
| -import Autotool.Data.Parallel.LazyTree (treesP) |
8 | 4 | main = do
|
9 |
| - let |
10 |
| - r = Op0 "r" $ parseIntRelation "{(1,1),(1,2),(2,1)}" |
11 |
| - -- s = Set "S" [ V(1 , 3), V(2 , 1), V(2 , 2) ] |
12 |
| - s = Op0 "s" $ parseIntRelation "{(1,3),(2,1),(2,2)}" |
13 |
| - -- t = S[ V(1 , 2) , V(2 , 3) ] |
14 |
| - t = parseIntRelation "{(1,3),(2,3)}" |
15 |
| - ops = [(+), (&), (-), (*), r, s] |
16 |
| - -- result = Node2 Subtr (Node2 Compose (Node0 r) (Node2 Subtr (Node0 s) (Node0 r))) (Node0 s) |
17 |
| - result = Node (-) [ |
18 |
| - Node (*) [ |
19 |
| - Node r [], |
20 |
| - Node (-) [ Node s [], Node r [] ] |
21 |
| - ], |
22 |
| - Node s [] |
23 |
| - ] |
24 |
| - ts = treesP ops |
25 |
| - st = let f a |
26 |
| - | a == r = "R" |
27 |
| - | a == s = "S" |
28 |
| - | otherwise = show a |
29 |
| - in showTreeFn f |
30 |
| - -- mapM_ (putStrLn . st) ts |
31 |
| - putStrLn $ showTree $ solve ops t |
| 5 | + args <- getArgs |
| 6 | + go args >>= putStrLn |
| 7 | + where |
| 8 | + go [command,filename] = do |
| 9 | + input <- readFile filename |
| 10 | + return $ app command input |
| 11 | + go _ = return help |
| 12 | + |
| 13 | +-- import Prelude hiding ((+), (-), (*)) |
| 14 | +-- import Autotool.Data.SetOp ( (&), (+), (-), pow ) |
| 15 | +-- import Autotool.Data.LazyTree (treesLevelCount, termsLength, trees, evalTree, showTreeFn, showTree, Tree(Node), Op(Op0), findTree) |
| 16 | +-- import Autotool.Solver.Sets (solve) |
| 17 | +-- import Autotool.Parser.NestedSet (parseIntSet) |
| 18 | +-- import Autotool.Data.Parallel.LazyTree (treesP) |
| 19 | +-- import Autotool.Data.NestedSet (toStr) |
| 20 | + |
| 21 | +-- main = do |
| 22 | +-- let |
| 23 | +-- a = Op0 "A" $ parseIntSet "{{}, {{}}}" |
| 24 | +-- b = Op0 "B" $ parseIntSet "{1, {1}, {2, {}}}" |
| 25 | +-- t = parseIntSet "{{}, {{}, {{}}}, {{{}}}}" |
| 26 | +-- ops = [(+), (-), (&), pow, a, b] |
| 27 | +-- result = |
| 28 | +-- Node (-) [ |
| 29 | +-- Node pow [ Node a [] ], |
| 30 | +-- Node (-) [ |
| 31 | +-- Node a [], |
| 32 | +-- Node pow [ |
| 33 | +-- Node (&) [ |
| 34 | +-- Node a [], |
| 35 | +-- Node b [] |
| 36 | +-- ] |
| 37 | +-- ] |
| 38 | +-- ] |
| 39 | +-- ] |
| 40 | +-- ts = trees ops |
| 41 | +-- -- mapM_ (putStrLn . showTree) (take 50000 ts) |
| 42 | +-- -- print $ let xs = [0..5] in zip xs $ map (treesLevelCount [2,1,3]) xs |
| 43 | +-- -- print $ let xs = [600..700] in zip xs $ map (termsLength [2,1,3]) xs |
| 44 | +-- -- print $ toStr $ evalTree result |
| 45 | +-- putStrLn $ showTree $ solve ops t |
32 | 46 |
|
0 commit comments