You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
361 B
18 lines
361 B
5 months ago
|
from sympy.core.basic import Basic
|
||
|
|
||
|
new = Basic.__new__
|
||
|
|
||
|
|
||
|
def assoc(d, k, v):
|
||
|
d = d.copy()
|
||
|
d[k] = v
|
||
|
return d
|
||
|
|
||
|
|
||
|
basic_fns = {'op': type,
|
||
|
'new': Basic.__new__,
|
||
|
'leaf': lambda x: not isinstance(x, Basic) or x.is_Atom,
|
||
|
'children': lambda x: x.args}
|
||
|
|
||
|
expr_fns = assoc(basic_fns, 'new', lambda op, *args: op(*args))
|