Ask Your Question

Running PARI/GP and Sage

asked 2011-06-30 04:35:14 +0200

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 12:15:47 +0200


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-30 04:35:14 +0200

Seen: 356 times

Last updated: Jun 30 '11