On Wed, Nov 12, 2008 at 8:36 AM, Andy Ray Terrel <[EMAIL PROTECTED]> wrote:
>
> On Wed, Nov 12, 2008 at 12:20 AM, Ondrej Certik <[EMAIL PROTECTED]> wrote:
>>
>> Hi Lance!
>>
>> On Tue, Nov 11, 2008 at 7:31 PM, llarsen <[EMAIL PROTECTED]> wrote:
>>>
>>> It seems like it would be nice where possible to make the sympy syntax
>>> as natural as possible. One area where it seems like this could be
>>
>> Absolutely, thanks for giving us a feedback.
>>
>>> done is in substitutions. I think it would be really slick support a
>>> substitution syntax like the following:
>>>
>>>    from sympy import *
>>>    x,y = symbols("xy")
>>>    f = x**2+y**2
>>>
>>>    # Substitute in x as 1 and y as 2
>>>    print f(x=1, y=2)
>>>
>>>    Output > 5
>>>
>>> Currently you can do this using:
>>>    print f.subs({x:1,y:2})
>>>
>>> However, f(x=1,y=2) is a more standard mathematical notation. It seems
>>> like this would be a rather trivial change. A __call__ method could be
>>> added to the Basic class (to make Basic objects callable as
>>> functions). The call method could just invoke the subs method directly
>>> and return the result. The subs could be modified to support the
>>> additional syntax:
>>>
>>>    f.subs(x=1, y=2)
>>>
>>> I am interested to hear what others think, but I really like the idea
>>> and think it would prove convenient.
>>
>> Thanks a lot for your suggestion. This is how Sage does it -- but it
>> has one drawback: it only works for symbols, but not if you are
>> substituting for x**2 or anything more complex. I personally see this
>> as some kind of a hack, as a misusing of keywords arguments,
>> but I think we can support this syntax, even though it would only work
>> for symbols. I think a lot of people want this. Others, what do you
>> think?
>>
>> Ondrej
>
>
> I have often found myself wanting to type something like this, so I'm for it.
>
> I would probably allow more things sage does, such as:
>
> sage: f = x*y
> sage: f(3,2)
> 6
> sage: f(3)
> 3*y
> sage: f(x,2)
> 2*x
> sage: f(x=3)
> 3*y
> sage: f(y=2)
> 2*x

Ok, let's do it.

Ondrej

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to