File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -137,9 +137,17 @@ namespace cadabra {
137137 auto ret = std::make_shared<Ex>(" \\ comma" );
138138
139139 for (const Ex_ptr& ex: exs) {
140- auto loc = ret->append_child (ret->begin (), ex->begin ());
141- if (*ex->begin ()->name ==" \\ comma" )
142- ret->flatten_and_erase (loc);
140+ // skip ex if empty
141+ if (ex->size () > 0 ) {
142+ auto loc = ret->append_child (ret->begin (), ex->begin ());
143+ if (*ex->begin ()->name ==" \\ comma" )
144+ ret->flatten_and_erase (loc);
145+ }
146+ }
147+ // Note: ret could still \comma{} or \comma{x}
148+ auto it = ret->begin ();
149+ if (ret->number_of_children (it) < 2 ) {
150+ ret->flatten_and_erase (it);
143151 }
144152 return ret;
145153 }
Original file line number Diff line number Diff line change @@ -333,6 +333,15 @@ def test14():
333333 ex4= join(ex1, ex2, ex3)
334334 assert(ex4==${A,C,D,E}$)
335335 print("Test 14g passed")
336+ ex1:= A;
337+ ex4 = join(ex1, Ex(""))
338+ assert(ex4==$A$)
339+ print("Test 14h passed")
340+ ex1:= A;
341+ ex2:= \comma{};
342+ ex4= join(ex1, ex2)
343+ assert(ex4==$A$)
344+ print("Test 14i passed")
336345
337346test14()
338347
You can’t perform that action at this time.
0 commit comments