04-05-2010, 05:57 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])
Lol, you and your lambda bologna
Terrorcore, unleash, extermination
Hyper real, cold blood, determination
fudge them, I like this sensation
Incredible, I from the annihilation