Skip to content

Instantly share code, notes, and snippets.

@radicaljims
Last active August 23, 2016 02:21
Show Gist options
  • Save radicaljims/786d9b5b801291dc59746245bdc7155f to your computer and use it in GitHub Desktop.
Save radicaljims/786d9b5b801291dc59746245bdc7155f to your computer and use it in GitHub Desktop.
import operator
import copy
todays = range(10)
yesterdays = copy.copy(todays)[1:]
# todays = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# yesterdays = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# now pair up a today with a yesterday...
todays_and_yesterdays = zip(todays, yesterdays)
# todays_and_yesterdays = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9)]
# ...and subtract!
deltas = map(lambda the_day_and_before: operator.sub(*the_day_and_before), todays_and_yesterdays)
# deltas = [-1, -1, -1, -1, -1, -1, -1, -1, -1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment