dear ondrej, thanks for the quick reply!
well, it is in the good direction. Indeed I would need to get rid of the funcion call parenthesis, even if that is not pythonic. I actually thought that _ could be a singleton object which, when its __add__, __mul__, ... are called, returns a subclass of Add, Mul, ... with a new unique symbol. f = _ + 10 f._args --> ('__tmp42345', 10) f2 = f + 5 f2._args --> ('__tmp42345', 15) f2(3) --> 18 any ideas? On Apr 1, 3:31 pm, "Ondrej Certik" <[EMAIL PROTECTED]> wrote: > On Tue, Apr 1, 2008 at 2:59 PM, atir ajnopse <[EMAIL PROTECTED]> wrote: > > > Hi. > > > I'm new to this list and was interested in sympy to use it to help > > implement a DSL for audio synthesis. > > > I had a question: I would like to have a symbol, say "_" --without the > > quotation marks ;-) , which creates unique copies of itself so that > > the following is possible: > > > f = _ + _ -> would behave as f = x + y (given x and y are Symbols), > > a bit like it is used in many functional languages (and not like 2 * > > _ ) > > > It should also be possible to then substitute each symbol with a value > > or with another symbol individually. > > Yep, that is easy, just append this at the end of my script above: > > print f.subs(Symbol("b"), 5) On Apr 1, 3:31 pm, "Ondrej Certik" <[EMAIL PROTECTED]> wrote: > On Tue, Apr 1, 2008 at 2:59 PM, atir ajnopse <[EMAIL PROTECTED]> wrote: > > > Hi. > > > I'm new to this list and was interested in sympy to use it to help > > implement a DSL for audio synthesis. > > > I had a question: I would like to have a symbol, say "_" --without the > > quotation marks ;-) , which creates unique copies of itself so that > > the following is possible: > > > f = _ + _ -> would behave as f = x + y (given x and y are Symbols), > > a bit like it is used in many functional languages (and not like 2 * > > _ ) > > > It should also be possible to then substitute each symbol with a value > > or with another symbol individually. > > Yep, that is easy, just append this at the end of my script above: > > print f.subs(Symbol("b"), 5) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---