Skip to content

Instantly share code, notes, and snippets.

@masahitojp
Created April 20, 2012 05:38
Show Gist options
  • Save masahitojp/2426343 to your computer and use it in GitHub Desktop.
Save masahitojp/2426343 to your computer and use it in GitHub Desktop.
>>> a = [i for i in xrange(10)]
>>> a
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> add_oddth = lambda lst:reduce(lambda a,b:a+b ,lst[0::2])
>>> add_oddth(a)
20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment