Ask Your Question

Claude Brisson's profile - activity

2023-05-30 13:16:59 +0200 received badge  Notable Question (source)
2022-04-04 22:07:43 +0200 received badge  Popular Question (source)
2017-10-20 14:36:59 +0200 commented answer how to inject a function?

Thanks, that's good to know.

2017-10-20 12:39:21 +0200 commented answer how to inject a function?

Thanks. The lambda construct did the trick. Numbering running suffixes are not applicable in my case, neither are dictionaries since positional parameters aren't yet functions at the time of the solving.

2017-10-20 12:37:36 +0200 received badge  Scholar (source)
2017-10-19 22:56:27 +0200 received badge  Student (source)
2017-10-19 18:46:29 +0200 asked a question how to inject a function?

One can inject variables using the inject_variable utility function:

from sage.misc.misc import inject_variable
inject_variable('foo', 'bar')

Now, how would it be possible to inject a function?

The context in which it is needed is the following one: I'm injecting the result of a resolution in the context as follow:

sol = solve([ ... ], f, g)
for s in sol[0]:
  inject_variable(str(s.lhs()),s.rhs());

but now I need to define f and g as parametrized by i, and things like inject_variable(str(s.lhs())+'(i)',s.rhs()) don't seem to work.