I wanted to pass functions as arguments, so your example solved my
problem,

thank you!

On Jul 18, 5:52 pm, "Justin C. Walker" <[EMAIL PROTECTED]> wrote:
> On Jul 18, 2008, at 12:04 , aniura wrote:
>
> > I have no experience in sage, I began to use it two days ago because I
> > need arbitrary precision arithmetic and Octave is not so god for
> > that.
>
> There are a number of good Python tutorials and other doc available.
> Check the site
>    <http://www.python.org>
> (I can't tell whether you have Python experience; Python is the
> implementation language for most of Sage).
>
> > I wanted to write a script where I evaluate a function which is also
> > written in a script. this can be done in Octave , f. ex. by using
> > "feval", but I have not found anything similar in sage. could anybody
> > give some suggestion?
>
> I'm not sure what you want from your description.  However:
>
> sage: def foo(x):
>     ...:         return bar(x)
>     ...:
> sage: def bar(y):
>     ....:         return y*y
>     ....:
> sage: foo(10)
>   100
>
> Is this what you mean?  'foo' and 'bar' can be defined in different
> files, as long as you have both files loaded when you call foo().  You
> can also pass functions as arguments:
>
> sage: def foo(x, f):
>     ....:     return f(x)
>     ....:
> sage: def bar(y):
>     ....:         return y*y
>     ....:
> sage: foo(10, bar)
>   100
>
> Does this help?  If not, please clarify; we're happy to help.
>
> Justin
>
> --
> They said it couldn't be done, but sometimes,
> it doesn't work out that way.
>    - Casey Stengel
> --
--~--~---------~--~----~------------~-------~--~----~
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://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to