First time here? Check out the FAQ!

Ask Your Question
0

Running PARI/GP and Sage

asked 13 years ago

anonymous user

Anonymous

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 13 years ago

Running

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

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.

Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 13 years ago

Seen: 428 times

Last updated: Jun 30 '11