nprimes.append(gp("prime("+str(i)+")"))

thanks

On 1/26/07, Justin C. Walker <[EMAIL PROTECTED]> wrote:
>
>
> On Jan 26, 2007, at 12:53 PM, Timothy Clemans wrote:
>
> >
> > ---------- Forwarded message ----------
> > From: Timothy Clemans <[EMAIL PROTECTED]>
> > Date: Jan 26, 2007 10:41 AM
> > Subject: bug in sage interface to pari?
> > To: William Stein <[EMAIL PROTECTED]>
> >
> >
> > Is the following, my own fault or a bug in sage?
> >
> > def nprimes(n):
> >  nprimes = []
> >  for i in range(n):
> >   nprimes.append(gp("prime(i)"))
> >  return nprimes
> >
> > produces:
> >
> > <type 'exceptions.TypeError'>: Error executing code in GP/PARI:
> > CODE:
> >         sage[3]=prime(i);
> > GP/PARI ERROR:
> >   ***   this should be an integer: sage[3]=prime(i);
>
> I think it's more of a feature than a bug.
>
> You've written "prime(i)", which is a string.  'i' in your program is
> unknown to 'gp', so it ('gp') doesn't know what to do with it ('i').
>
> You could do something like
>       nprimes.append(gp("prime("+str(i)+))"))
> (and you want "range(1,n)", since 'prime(0)' is undefined ;-})
>
> Justin
>
> --
> Justin C. Walker, Curmudgeon-At-Large, Director
> Institute for the Enhancement of the Director's Income
> --------
> The path of least resistance:
> it's not just for electricity any more.
> --------
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to