File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,23 @@ import * as herbiejs from '../lib/herbiejs';
44import { LocalErrorTree } from "../HerbieTypes" ;
55import "./newLocalError.css" ;
66
7+ const opMap : Record < string , string > = {
8+ "+" : "add" ,
9+ "-" : "sub" ,
10+ "*" : "mul" ,
11+ "/" : "div"
12+ } ;
13+
14+ function mapOp ( e : string ) {
15+ return opMap [ e ] ?? e ;
16+ }
17+
718function formatExpression ( node : LocalErrorTree ) : string {
19+ const expr = mapOp ( node . e ) ;
820 if ( ! node . children || node . children . length === 0 ) {
9- return node . e ;
21+ // return node.e;
22+ return expr ;
23+
1024 }
1125 if ( [ "sqrt" , "pow" , "log" ] . includes ( node . e ) ) {
1226 return `${ node . e } (${ node . children . map ( formatExpression ) . join ( ", " ) } )` ;
@@ -103,7 +117,7 @@ function TreeRow({
103117 ) }
104118 </ span >
105119 ) }
106- { isExpanded ? node . e : collapsedExpression }
120+ { isExpanded ? mapOp ( node . e ) : collapsedExpression }
107121 </ span >
108122 </ td >
109123 < td className = "border px-4 py-2" > { renderValue ( node [ "actual-value" ] ) } </ td >
You can’t perform that action at this time.
0 commit comments