Can I read a Gap file into my current Gap session within Sage?

i like this post (click again to cancel)
i dont like this post (click again to cancel)

I have a collection of functions defined for Gap, and I'd like to be able to read their definitions and use them from Sage. I've noticed the load_package function, but this seems to require that my function definitions be installed as a Gap package. I'd like to be able to do something like

sage: gap('Read("gap_defs.g");')

and then

sage: X = gap('customFunction()')

to return the Sage-wrapped output of my gap function. However this doesn't seem to work, and nor do any of the (many) variants I've tried. Suggestions?

If installing the definitions as a Gap package is necessary, could someone tell me where the files should be put so that Sage's copy of Gap can find them? (i.e. what is the Gap root for Sage's Gap?)

asked Dec 11 '10

niles gravatar image niles
3725 7 45 104

updated Apr 28 '11

Kelvin Li gravatar image Kelvin Li
453 1 10 17
i like this answer (click again to cancel)
i dont like this answer (click again to cancel) niles has selected this answer as correct

You should be able to do the following:

sage: gap.Read('"gap_defs.g"') #similarly gap.eval('Read("gap_defs.g");')
sage: X = gap.customFunction() #assuming customFunction() returns an object

If that isn't working for you, you'll have to be more specific as to what the error is.

Note that doing

sage: gap('Read("gap_defs.g");')

is equivalent to doing something like

sage24 := Read("gap_defs.g");

in GAP. If you want to just evaluate a command in the session, use gap.eval('XXX').


posted Dec 11 '10

Mike Hansen gravatar image Mike Hansen flag of United States
3890 23 46 84
just what I needed -- thanks! niles (Dec 11 '10)

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
Login/Signup to Post

Question tools



Asked: Dec 11 '10

Seen: 132 times

Last updated: Dec 11 '10

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.