@@ -649,32 +649,27 @@ function to_standard(arg::BinaryOperation{Mult})
649649 l = to_standard (arg. arg1)
650650 r = to_standard (arg. arg2)
651651
652- term = nothing
652+ attempt = BinaryOperation {Mult} (l, r)
653+ if get_free_indices (attempt) == target_indices
654+ return attempt
655+ end
653656
654- # TODO : Refactor
655- if get_free_indices (BinaryOperation {Mult} (l, r)) == target_indices
656- term = BinaryOperation {Mult} (l, r)
657- elseif get_free_indices (BinaryOperation {Mult} (radjoint (l), r)) == target_indices
658- term = BinaryOperation {Mult} (radjoint (l), r)
659- elseif get_free_indices (BinaryOperation {Mult} (l, radjoint (r))) == target_indices
660- term = BinaryOperation {Mult} (l, radjoint (r))
661- elseif get_free_indices (BinaryOperation {Mult} (radjoint (l), radjoint (r))) ==
662- target_indices
663- term = BinaryOperation {Mult} (radjoint (l), radjoint (r))
664- elseif length (get_free_indices (BinaryOperation {Mult} (l, r))) == target_len
665- term = BinaryOperation {Mult} (l, r)
666- elseif length (get_free_indices (BinaryOperation {Mult} (radjoint (l), r))) == target_len
667- term = BinaryOperation {Mult} (radjoint (l), r)
668- elseif length (get_free_indices (BinaryOperation {Mult} (l, radjoint (r)))) == target_len
669- term = BinaryOperation {Mult} (l, radjoint (r))
670- elseif length (get_free_indices (BinaryOperation {Mult} (radjoint (l), radjoint (r)))) ==
671- target_len
672- term = BinaryOperation {Mult} (radjoint (l), radjoint (r))
673- else
674- throw_not_std (arg)
657+ attempt = BinaryOperation {Mult} (radjoint (l), r)
658+ if get_free_indices (attempt) == target_indices
659+ return attempt
675660 end
676661
677- return term
662+ attempt = BinaryOperation {Mult} (l, radjoint (r))
663+ if get_free_indices (attempt) == target_indices
664+ return attempt
665+ end
666+
667+ attempt = BinaryOperation {Mult} (radjoint (l), radjoint (r))
668+ if get_free_indices (attempt) == target_indices
669+ return attempt
670+ end
671+
672+ throw_not_std (arg)
678673end
679674
680675"""
0 commit comments