If you want to interact with PARI/GP it is much better (= faster and
more reliable) to use the cypari interface. Namely
sage: s = pari('square(x)=x^2')
sage: s(20)
400
If you want to convert the output of s(20) (a "Gen") then use
sage: s(20).sage()
400
sage: type(s20)
sage: type(s(20).sage())
Thank you, it works!
On Sun, Jan 12, 2020 at 7:54 PM Dima Pasechnik wrote:
> e.g. something like
>
> sage: gp.eval("square(x)=x^2")
> '(x)->x^2'
> sage: gp.function_call("square",[20]).sage()
> 400
>
> So one can have
>
> def foo(x):
> return gp.function_call("square",[x]).sage()
>
> to crea
e.g. something like
sage: gp.eval("square(x)=x^2")
'(x)->x^2'
sage: gp.function_call("square",[20]).sage()
400
So one can have
def foo(x):
return gp.function_call("square",[x]).sage()
to create a Sage function that will square a number using GP
On Sun, Jan 12, 2020 at 2:26 PM Dima Pasechni
this way Python does not know anything about GP functions.
You need to pass the input/output from/to Python.
On Sun, 12 Jan 2020, 14:06 Pedja, wrote:
> Why the following code doesn't work inside Sage Cell?
>
> gp("""
> square(x)=x^2;
> """)
> @interactdef _(x=2):
> print(square(x))
>
> --
>
Why the following code doesn't work inside Sage Cell?
gp("""
square(x)=x^2;
""")
@interactdef _(x=2):
print(square(x))
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an