diff --git a/mathics/builtin/forms/other.py b/mathics/builtin/forms/other.py index acca73a60..cdde00782 100644 --- a/mathics/builtin/forms/other.py +++ b/mathics/builtin/forms/other.py @@ -9,6 +9,50 @@ from mathics.builtin.makeboxes import MakeBoxes from mathics.core.atoms import String from mathics.core.element import EvalMixin +from mathics.eval.strings import eval_ToString + + +class SequenceForm(FormBaseClass): + """ + + :WMA link: + https://reference.wolfram.com/language/ref/SequenceForm.html + +
+
'SequenceForm[$expr1$, $expr2$, ..]' +
format the textual concatenation of the printed forms of $expi$. +
+ 'SequenceForm' has been superseded by :Row: + /doc/reference-of-built-in-symbols/layout/row + and 'Text' (which is not implemented yet). + + >> SequenceForm["[x = ", 56, "]"] + = [x = 56 ]" + """ + + in_outputforms = False + in_printforms = False + + options = { + "CharacterEncoding": '"Unicode"', + } + + summary_text = "format make an string from a template and a list of parameters" + + def eval_makeboxes(self, args, form, evaluation, options: dict): + """MakeBoxes[SequenceForm[args___, OptionsPattern[SequenceForm]], + form:StandardForm|TraditionalForm|OutputForm]""" + encoding = options["System`CharacterEncoding"] + return RowBox( + *[ + ( + arg + if isinstance(arg, String) + else eval_ToString(arg, form, encoding.value, evaluation) + ) + for arg in args.get_sequence() + ] + ) class StringForm(FormBaseClass): @@ -31,9 +75,9 @@ class StringForm(FormBaseClass): in_printforms = False summary_text = "make an string from a template and a list of parameters" - def eval_makeboxes(self, s, args, f, evaluation): + def eval_makeboxes(self, s, args, form, evaluation): """MakeBoxes[StringForm[s_String, args___], - f:StandardForm|TraditionalForm|OutputForm]""" + form:StandardForm|TraditionalForm|OutputForm]""" s = s.value args = args.get_sequence() @@ -53,7 +97,7 @@ def eval_makeboxes(self, s, args, f, evaluation): if 1 <= index <= len(args): arg = args[index - 1] result.append( - to_boxes(MakeBoxes(arg, f).evaluate(evaluation), evaluation) + to_boxes(MakeBoxes(arg, form).evaluate(evaluation), evaluation) ) if pos < len(s): result.append(to_boxes(String(s[pos:]), evaluation)) diff --git a/mathics/packages/Combinatorica-repo b/mathics/packages/Combinatorica-repo index 493613881..3531967c5 160000 --- a/mathics/packages/Combinatorica-repo +++ b/mathics/packages/Combinatorica-repo @@ -1 +1 @@ -Subproject commit 493613881a2928787ada0c75d80c26568f5712d1 +Subproject commit 3531967c57ab8304352365e7730d78d5c022df23