Skip to content

Instantly share code, notes, and snippets.

@skatenerd
Last active August 29, 2015 14:18
Show Gist options
  • Save skatenerd/9766f984d1bd6dcebe2b to your computer and use it in GitHub Desktop.
Save skatenerd/9766f984d1bd6dcebe2b to your computer and use it in GitHub Desktop.
def generate_inverse_transformations(left,right):
#?????
return (lambda x: x, lambda x: x)
left_form = {
'key': 'abc123',
'name': {'first': 'joe', 'last': 'stein'},
'triples': {1: 3, 2: 6, 3: 9, 4: 12, 5: 15},
'opposites': [('low','high'),('big','small')]
}
right_form = {
'uuid': 'abc123',
'first_name': 'joe',
'last_name': 'stein',
'triple_tuples': [(1, 3), (2, 6), (3, 9), (4, 12), (5, 15)],
'opposites': [{'first': 'low', 'second': 'high'}, {'first': 'big', 'second': 'small'}]
}
#IMPLEMENT generate_inverse_transformations()
# So that, when:
#f, g = generate_inverse_transformations(left_form, right_form)
# THEN:
#f(left) == right
#g(right) == left
#f(g(right)) == right
# For any (left, right) of the same structure as left_form and right_form
#More specifically, if we have:
specific_input = {
'key': 'defghi',
'name': {'first': 'slug', 'last': 'ant'},
'triples': {1:2, 3:4},
'opposites': []
}
#Then, f(specific) should yield:
specific_output = {
'uuid': 'defghi',
'first_name': 'slug',
'last_name': 'ant',
'triple_tuples': (1,2), (3,4)},
'opposites': []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment