04-06-2010, 04:17 PM
(02-18-2010, 09:45 PM)uber1337 Wrote: map/filter equivalent:
Yep. Your way is better ;)Code:sum = []
for x in range(1000):
sum.append(x)
sum = filter(lambda x : x % 3 == 0 or x % 5 == 0, sum)
sum = reduce(lambda x, y: x + y, sum)
print sum
Edit:
One liner FTW!
Code:reduce(lambda x,y : x+y, [x for x in xrange(1000) if x % 3 == 0 or x % 5 == 0])
One liner FTW!
Code:
print sum([x for x in xrange(1000) if x % 3 == 0 or x % 5 == 0])
Terrorcore, unleash, extermination
Hyper real, cold blood, determination
fudge them, I like this sensation
Incredible, I from the annihilation