Ask Your Question

gap record

asked 2015-01-05 23:43:53 +0200

vdelecroix gravatar image

updated 2015-06-30 08:56:59 +0200


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 12:13:51 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-30 14:16:07 +0200

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 23:43:53 +0200

Seen: 634 times

Last updated: Jun 30 '15