Skip to content

Instantly share code, notes, and snippets.

@eyaltrabelsi
Created June 21, 2019 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyaltrabelsi/b81874b8e01066bbb3a5c4aa15415f96 to your computer and use it in GitHub Desktop.
Save eyaltrabelsi/b81874b8e01066bbb3a5c4aa15415f96 to your computer and use it in GitHub Desktop.
Python trick cumulitive sum all elements in iterable o
>>> import numpy as np
>>> res = list(np.cumsum(range(0,10,2)))
>>> res
[ 0, 2, 6, 12, 20]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment