Thanks.

On 2/7/07, Martin Albrecht <[EMAIL PROTECTED]> wrote:
>
> On Wednesday 07 February 2007 07:32, Timothy Clemans wrote:
> > Hi I would like to write functions that return equations. I would like
> > to know what the preferred method in SAGE for doing so is.
>
> There are two ways: Implement an equation class which does what ever you want
> and construct it from your function.
>
> If you can live with a function instead of an equation try:
>
> def line_two_points(a,b):
>     m = (b[1]-a[1])/(b[0]-a[0])
>     return lambda x: m*x +(a[1]-m*a[0])
>
> sage: f = line_two_points((0,0),(1,1))
> sage: f(2)
> 2
>
> Some stuff you may want to look up:
>  * http://en.wikipedia.org/wiki/Anonymous_function
>  * http://docs.python.org/ref/lambdas.html
>  * http://docs.python.org/ref/callable-types.html
>  * http://sage.scipy.org/sage/doc/html/prog/node14.html
>
> Have fun,
> Martin
>
>
> --
> name: Martin Albrecht
> _pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
> _www: http://www.informatik.uni-bremen.de/~malb
> _jab: [EMAIL PROTECTED]
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to