By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,688 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,688 IT Pros & Developers. It's quick & easy.

Re: advanced listcomprehenions?

P: n/a
Terry Reedy <tj*****@udel.eduwrote:
>[['Fizz', 'Buzz', 'FizzBuzz', str(i)][62/(pow(i, 4, 15) + 1)%4] for i
in xrange(1, 101)]

These make the lookup table variable, so it has to be recalculated for
each i.
So what? Mark Wooding was posting about mathematical elegance and came up
with that really neat pow() call. If runtime came into it then one of the
previous solutions or (as Mark already said) a straightforward sometable[i%
15] is going beat something like this hands-down.

This is coding for fun not profit.

--
Duncan Booth http://kupuguy.blogspot.com
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply

P: n/a
On 20 , 11:31, Duncan Booth <duncan.bo...@invalid.invalidwrote:
Terry Reedy <tjre...@udel.eduwrote:
[['Fizz', 'Buzz', 'FizzBuzz', str(i)][62/(pow(i, 4, 15) + 1)%4] for i
in xrange(1, 101)]
These make the lookup table variable, so it has to be recalculated for
each i.

So what? Mark Wooding was posting about mathematical elegance and came up
with that really neat pow() call. If runtime came into it then one of the
previous solutions or (as Mark already said) a straightforward sometable[i%
15] is going beat something like this hands-down.

This is coding for fun not profit.

--
Duncan Boothhttp://kupuguy.blogspot.com
I can't resist...
[[i,"Fizz","Buzz","FizzBuzz"][(not i%3)+(not i%5)*2] for i in range(1,
101)]

Ivan
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.