To the people who kindly replied to my question: many thanks!
On 10/31/2013 06:29 PM, Danny Yoo wrote:
As an aside: It shouldn't be too bad to write a "generator" for the
geometric series, so that we can pick out the terms on-demand.
#
>>> def geometric(base):
As an aside: It shouldn't be too bad to write a "generator" for the
geometric series, so that we can pick out the terms on-demand.
#
>>> def geometric(base):
... x = 1
... while True:
... yield x
... x *= base
...
>>> twos = geometric(2)
On 31.10.2013 04:00, bob gailer wrote:
On 10/30/2013 1:08 PM, Peter O'Doherty wrote:
Hi List,
I know a geometric sequence can be produced by:
series = [2**x for x in range(7)]
But I would like to curtail the sequence before the last element
excedes a certain value.
import itertools
series =
On 10/30/2013 1:08 PM, Peter O'Doherty wrote:
Hi List,
I know a geometric sequence can be produced by:
series = [2**x for x in range(7)]
But I would like to curtail the sequence before the last element
excedes a certain value.
import itertools
series = [2**x for x in itertools.takewhile(lamb
On 30/10/2013 13:08, Peter O'Doherty wrote:
> Hi List,
>
> I know a geometric sequence can be produced by:
>
> series = [2**x for x in range(7)]
>
> But I would like to curtail the sequence before the last element excedes
> a certain value. Is there a better way of doing it that the following:
>
On Oct 31, 2013 12:10 AM, "Mark Lawrence" wrote:
>
> On 30/10/2013 17:08, Peter O'Doherty wrote:
>>
>> Hi List,
>>
>> I know a geometric sequence can be produced by:
>>
>> series = [2**x for x in range(7)]
>>
>> But I would like to curtail the sequence before the last element excedes
>> a certain
On 30/10/2013 17:08, Peter O'Doherty wrote:
Hi List,
I know a geometric sequence can be produced by:
series = [2**x for x in range(7)]
But I would like to curtail the sequence before the last element excedes
a certain value. Is there a better way of doing it that the following:
for x in range
On 30/10/13 17:08, Peter O'Doherty wrote:
Hi List,
I know a geometric sequence can be produced by:
series = [2**x for x in range(7)]
But I would like to curtail the sequence before the last element excedes
a certain value.
You can add an if clause to the comprehension:
series = [2**x for x
Hi List,
I know a geometric sequence can be produced by:
series = [2**x for x in range(7)]
But I would like to curtail the sequence before the last element excedes
a certain value. Is there a better way of doing it that the following:
for x in range(20):
series_element = 2**x
print s