def apply(self, string, evaluation): "Symbol[string_String]" from mathics.core.parser import is_symbol_name text = string.get_string_value() if is_symbol_name(text): return Symbol(evaluation.definitions.lookup_name(string.value)) else: evaluation.message("Symbol", "symname", string)
def apply(self, string, evaluation): 'Symbol[string_String]' from mathics.core.parser import is_symbol_name text = string.get_string_value() if is_symbol_name(text): return Symbol(string.value) else: evaluation.message('Symbol', 'symname', string)
def apply(self, string, evaluation): 'Symbol[string_String]' from mathics.core.parser import is_symbol_name text = string.get_string_value() if is_symbol_name(text): return Symbol(evaluation.definitions.lookup_name(string.value)) else: evaluation.message('Symbol', 'symname', string)
def apply(self, string, evaluation): "Symbol[string_String]" from mathics.core.parser import is_symbol_name text = string.get_string_value() if is_symbol_name(text): return Symbol(string.value) else: evaluation.message("Symbol", "symname", string)
def apply_symbol(self, vars, attributes, evaluation): "Unique[vars_, attributes___]" from mathics.core.parser import is_symbol_name from mathics.builtin.attributes import get_symbol_list attributes = attributes.get_sequence() if len(attributes) > 1: return evaluation.message("Unique", "argrx", Integer(len(attributes) + 1)) # Check valid symbol variables symbols = vars.leaves if vars.has_form("List", None) else [vars] for symbol in symbols: if not isinstance(symbol, Symbol): text = symbol.get_string_value() if text is None or not is_symbol_name(text): return evaluation.message("Unique", "usym", symbol) # Check valid attributes attrs = [] if len(attributes) > 0: attrs = get_symbol_list( attributes[0], lambda item: evaluation.message("Unique", "attnf", item)) if attrs is None: return None # Generate list new symbols list = [] for symbol in symbols: if isinstance(symbol, Symbol): list.append( Module(Expression("List", symbol), symbol).evaluate(evaluation)) else: new_name = "%s%d" % (symbol.get_string_value(), self.seq_number) self.seq_number += 1 # Next symbol in case of new name is defined before while evaluation.definitions.get_definition(new_name, True) is not None: new_name = "%s%d" % (symbol.get_string_value(), self.seq_number) self.seq_number += 1 list.append(Symbol(new_name)) for symbol in list: for att in attrs: evaluation.definitions.set_attribute(symbol.get_name(), att) if vars.has_form("List", None): return Expression("List", *list) else: return list[0]