Skip to content

Commit 382298b

Browse files
committed
fix
1 parent 3edae45 commit 382298b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

hs-src/Language/Egison/MathOutput.hs

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ This module provides utility functions.
88

99
module Language.Egison.MathOutput (mathExprToHaskell, mathExprToAsciiMath, mathExprToLatex, mathExprToMathematica) where
1010

11-
import Data.List (intercalate)
1211
import Control.Monad
1312
import System.Environment
1413
import Text.ParserCombinators.Parsec hiding (spaces)
1514

1615
mathExprToHaskell :: String -> String
1716
mathExprToHaskell input = case parse parseExpr "math-expr" input of
1817
Left err -> input
19-
Right val -> "#haskell\"" ++ show val ++ "\""
18+
Right val -> "#haskell|" ++ show val ++ "|#"
2019

2120
mathExprToAsciiMath :: String -> String
2221
mathExprToAsciiMath input = case parse parseExpr "math-expr" input of
2322
Left err -> input
24-
Right val -> "#asciimath\"" ++ showMathExprAsciiMath val ++ "\""
23+
Right val -> "#asciimath|" ++ showMathExprAsciiMath val ++ "|#"
2524

2625
mathExprToLatex :: String -> String
2726
mathExprToLatex input = case parse parseExpr "math-expr" input of
@@ -132,6 +131,7 @@ showMathExprLatex (Plus (x:xs)) = showMathExprLatex x ++ showMathExprLatexForPlu
132131
showMathExprLatexForPlus :: [MathExpr] -> String
133132
showMathExprLatexForPlus [] = ""
134133
showMathExprLatexForPlus ((NegativeAtom a):xs) = " - " ++ a ++ showMathExprLatexForPlus xs
134+
showMathExprLatexForPlus ((Multiply (NegativeAtom "1":ys)):xs) = " - " ++ showMathExprLatex (Multiply ys) ++ showMathExprLatexForPlus xs
135135
showMathExprLatexForPlus ((Multiply (NegativeAtom a:ys)):xs) = " - " ++ showMathExprLatex (Multiply ((Atom a []):ys)) ++ showMathExprLatexForPlus xs
136136
showMathExprLatexForPlus (x:xs) = " + " ++ showMathExprLatex x ++ showMathExprLatexForPlus xs
137137
showMathExprLatex (Multiply []) = ""
@@ -195,6 +195,7 @@ showMathExprMathematica (Plus (x:xs)) = showMathExprMathematica x ++ showMathExp
195195
showMathExprMathematicaForPlus :: [MathExpr] -> String
196196
showMathExprMathematicaForPlus [] = ""
197197
showMathExprMathematicaForPlus ((NegativeAtom a):xs) = " - " ++ a ++ showMathExprMathematicaForPlus xs
198+
showMathExprMathematicaForPlus ((Multiply (NegativeAtom "1":ys)):xs) = " - " ++ showMathExprMathematica (Multiply ys) ++ showMathExprMathematicaForPlus xs
198199
showMathExprMathematicaForPlus ((Multiply (NegativeAtom a:ys)):xs) = " - " ++ showMathExprMathematica (Multiply ((Atom a []):ys)) ++ showMathExprMathematicaForPlus xs
199200
showMathExprMathematicaForPlus (x:xs) = " + " ++ showMathExprMathematica x ++ showMathExprMathematicaForPlus xs
200201
showMathExprMathematica (Multiply []) = ""

0 commit comments

Comments
 (0)