Comment #30 on issue 1337 by mattpap: find all instances in an expression
http://code.google.com/p/sympy/issues/detail?id=1337
I went ahead and implemented preliminary version of replace(), e.g.:
In [1]: f = log(sin(x)) + tan(sin(x**2))
In [2]: a = Wild('a')
In [3]: f.replace(sin(a), cos(a))
Out[3]:
⎛ ⎛ 2⎞⎞
log(cos(x)) + tan⎝cos⎝x ⎠⎠
In [4]: X = numbered_symbols('x')
In [5]: (sin(x) + f).replace(sin, lambda _: X.next(), map=True)
Out[5]:
⎛ ⎧ ⎛ 2⎞ ⎫⎞
⎜x₁ + log(x₀) + tan(x₂), ⎨sin(x): set(x₀, x₁), sin⎝x ⎠: set(x₂)⎬⎟
⎝ ⎩ ⎭⎠
(c984db33c7bb6135d1a33605b8c0b9afd102577d in polys12). See the docstring
for details.
--
You received this message because you are subscribed to the Google Groups
"sympy-patches" group.
To post to this group, send email to sympy-patc...@googlegroups.com.
To unsubscribe from this group, send email to
sympy-patches+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-patches?hl=en.