On 6/11/07, mak <[EMAIL PROTECTED]> wrote:
>
> What is the sage translation of PARI's
>
> forstep(i=1,0,-.1,<commands>)?

The SAGE translation of this is:

sage: for n in srange(1,-.1,-.1):
...       print n, n^2
1 1
0.900000000000000 0.810000000000000
0.800000000000000 0.640000000000000
0.700000000000000 0.490000000000000
0.600000000000000 0.360000000000000
0.500000000000000 0.250000000000000
0.400000000000000 0.160000000000000
0.300000000000000 0.0900000000000000
0.200000000000000 0.0400000000000000
0.100000000000000 0.0100000000000000
0.000000000000000 0.000000000000000


In sage/python range and srange do not include the
finishing endpoint, which is why it's
     srange(1,-.1,-.1) instead of srange(1,0,-.1).

> Why does 'for?' not produce any help with loops?

Because for is not an object or function, and ? currently
only works on objects and functions.  I definitely want
to change this, i.e., think ? should work for languages
constructions like for, while, etc.

> Is there any way to search the documentation for help on a topic like
> this?

srange would be hard to find in the documentation.  Python has a builtin
range command which is a bit less flexible (but faster) than the srange
command, and is discussed at length in any of the python documentation.

If you do a google search for "python for loop" (no quotes) you'll get lots
of potentially useful and relevant pages.

 -- William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
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