-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalcSimb.hs
55 lines (49 loc) · 2.07 KB
/
calcSimb.hs
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
53
54
55
import Term
import Algebra
import Antidiff
simplifyIO :: Term -> IO Term
simplifyIO x
| x == y = return x
| otherwise = do {appendFile "index.html" $ "$$="++(show y)++"$$\n"; return y}
where
y = simplify x
powIO :: Term -> IO Term
powIO x
| x == y = return x
| otherwise = do {appendFile "index.html" $ "$$="++(show y)++"$$\n"; return y}
where
y = pow x
distribIO :: Term -> IO Term
distribIO x
| x == y = return x
| otherwise = do {appendFile "index.html" $ "$$="++(show y)++"$$\n"; return y}
where
y = distrib x
groupAtomsIO :: Term -> IO Term
groupAtomsIO x
| x == y = return x
| otherwise = do {appendFile "index.html" $ "$$="++(show y)++"$$\n"; return y}
where
y = groupAtoms x
simbIntIO :: Term -> IO Term
simbIntIO x
| x == y = return x
| otherwise = do {appendFile "index.html" $ "$$="++(show y)++"$$\n"; return y}
where
y = simbInt x
solve :: Term -> IO Term
solve x = do {writeFile "index.html" $ "<html>\n"
++ "<head>\n"
++ "<link rel=\"stylesheet\" href=\"http://stilgar.ldc.usb.ve/Aledania/static/css/bootstrap.min.css\" >\n"
++ "<script src=\"http://stilgar.ldc.usb.ve/Aledania/static/js/bootstrap.min.js\"></script>\n"
++ "<script type=\"text/javascript\" src=\"http://stilgar.ldc.usb.ve/Aledania/static/js/mathjax-MathJax-v2.3-248-g60e0a8c/MathJax.js?config=TeX-AMS-MML_HTMLorMML\">\n"
++ "</script>\n"
++ "</head>\n"
++ "<body>\n";
appendFile "index.html" $ "$$" ++ (show $ groupAtoms x) ++ "$$\n";
solveAux (Const 1 1) (groupAtoms x)}
where
solveAux :: Term -> Term -> IO Term
solveAux x y
| x == y = do {appendFile "index.html" "</body>\n</html>\n"; return x}
| otherwise = return y >>= simbIntIO >>= powIO >>= distribIO >>= groupAtomsIO >>= simplifyIO >>= (solveAux y)