Ask Your Question

gap record

asked 2015-01-05 16:43:53 -0600

updated 2015-06-30 01:56:59 -0600


I would like to manipulate gap records (association name -> value) through sage... but it does not seem available. Here is a sample from GAP

gap> rec( a := 1, b := "deux" );
rec( a := 1, b := "deux" )
gap> r.a;
gap> r.b;

But in Sage

sage: w = gap('rec( a := 1, b := "deux" );')
sage: w
  a := 1,
  b := "deux" )
sage: w.a
sage: w.b

Which is very strange!! Hopefully, it is still possible to do

sage: gap("{}.a".format(w._name))
sage: gap("{}.b".format(w._name))

Is there a better way to deal with them?

Thanks Vincent

edit retag flag offensive close merge delete


GAP 4.7.7 (February 2015) fixed a bug where recursive records might be printed with the wrong component name, coming from component names being ordered differently in two different pieces of code (see here). Could this be related? Is this reproducible with GAP 4.7.7 or 4.7.8?

alexander konovalov gravatar imagealexander konovalov ( 2015-06-24 05:13:51 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-06-30 07:16:07 -0600

nbruin gravatar image

It looks like you can do it via the libgap library interface:

sage: w = libgap.eval('rec( a := 1, b := "deux" );')
sage: w['a']
sage: w['b']
sage: w2 = libgap({'a':1,'b':'deux'})
sage: w == w2

(note that gap records are quite like associative arrays, so letting them correspond to python dicts seems a reasonable interface design. It doesn't look like this mapping was taken into consideration in the pexpect based interface)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-01-05 16:43:53 -0600

Seen: 150 times

Last updated: Jun 30 '15