1 | initial version |
An alternative is to create a Sage (Python) function explicitly manipulating Gap objects. An example is needed to illustrate...
Note that you can also define "one liner" GAP functions (analogous to Sage's callable symbolic expressions, a.k.a symbolic functions) with the ->
Gap operator. Compare :
sage: bar=libgap.eval('x->x^3')
sage: type(bar)
<class 'sage.libs.gap.element.GapElement_Function'>
sage: bar.parent()
C library interface to GAP
sage: bar
<Gap function "unknown">
sage: bar(5)
125
with
sage: gee(x)=x^3
sage: type(gee)
<class 'sage.symbolic.expression.Expression'>
sage: gee.parent()
Callable function ring with argument x
sage: gee
x |--> x^3
sage: gee(5)
125
Note that this is not implemended in the pexpect
gap interface.
sage: quux=gap.eval('x->x^3')
sage: quux(5)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[108], line 1
----> 1 quux(Integer(5))
TypeError: 'str' object is not callable
sage: quux
'function( x ) ... end'
HTH,
2 | No.2 Revision |
An alternative is to create a Sage (Python) function explicitly manipulating Gap objects. An example is needed to illustrate...
Note that you can also define "one liner" GAP functions (analogous to Sage's callable symbolic expressions, a.k.aa.k.a. symbolic functions) with the ->
Gap operator. Compare :
sage: bar=libgap.eval('x->x^3')
sage: type(bar)
<class 'sage.libs.gap.element.GapElement_Function'>
sage: bar.parent()
C library interface to GAP
sage: bar
<Gap function "unknown">
sage: bar(5)
125
with
sage: gee(x)=x^3
sage: type(gee)
<class 'sage.symbolic.expression.Expression'>
sage: gee.parent()
Callable function ring with argument x
sage: gee
x |--> x^3
sage: gee(5)
125
Note that this is not implemended in the pexpect
gap interface.
sage: quux=gap.eval('x->x^3')
sage: quux(5)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[108], line 1
----> 1 quux(Integer(5))
TypeError: 'str' object is not callable
sage: quux
'function( x ) ... end'
More generally, the pexpect
and library interfaces to Gap seem quite different in intent and possible uses. Compare the pexpect interface to the library interface.
HTH,