On Wed, Oct 28, 2009 at 3:46 PM, Erik <[email protected]> wrote:
>
> The first two solutions did what I intended. The 3rd one did not, but
> I may have erred.
>
> Is the use of "_" documented anywhere?

It is discussed in the Python tutorial pretty quickly:

     http://docs.python.org/tutorial/introduction.html

It is a really good idea to read that, and we should probably encourage it more.

>  Does my difficulty finding it
> suggest it should be described in either the tutorial or FAQ? I
> suspect it is commonly used.
>
> Thanks everyone for your assistance.
>
> On Oct 28, 12:18 pm, Marshall Hampton <[email protected]> wrote:
>> Slightly different solution to generate and store the values:
>>
>> def f(x):
>>     return (1/5)*(x**3+x**2-3)
>> answers = [f(0)]
>> for i in range(5):
>>     answers.append(f(answers[-1]))
>>
>> ..and then answers will be a list of the first 6 iterated values.
>>
>> -Marshall Hampton
>>
>> On Oct 28, 8:55 am, Erik <[email protected]> wrote:
>>
>>
>>
>> > I would like to iterate a function:
>>
>> > def f(x):
>> >     return( (1/5)*(x**3+x**2-3) )
>> > f(0)
>>
>> > Running evaluate on the above yields the quantity -3/5. Rather than
>> > evaluating f(-3/5), is there a way to reference the previous output
>> > from evaluate, i.e. to evaluate f(previous) or some similar syntax?
>> > Similarly, is there a way to use the syntax "for i in range()" to
>> > define the next i as f(i)? I know that "for i in range(-2,2,i=f(i))"
>> > does not work. I've briefly searched the tutorial, this Google group,
>> > and Google generally without finding solutions. However, today is my
>> > first day using Sage.
>>
>> > I'm running  Sage 4.1.2 pre-compiled 32 bit binary for Debian Lenny.
>>
>> > Thanks.
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
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
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to