Ask Your Question

Running PARI/GP and Sage

asked 2011-06-29 21:35:14 -0600

anonymous user


Suppose I have a function a(i) in PARI/GP code. To evaluate something like a(5) in sage code I write pari('a[5]'). However, running the for loop on pari('a[i]') doesn't seem to work. Is there a work around for this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2011-06-30 05:15:47 -0600


for i in range(n):

won't work since 'a[i]' is a string. Try something like this instead:

for i in range(n):
    pari('a[%d]' %(i))

This will actually substitute the values i takes on into the string expressions you want to evaluate.

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


Asked: 2011-06-29 21:35:14 -0600

Seen: 148 times

Last updated: Jun 30 '11