From f666fcb67de7ed9893873dc87462716bef0155b3 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sun, 1 Sep 2013 15:57:02 -0500 Subject: move flatten and flattener into helpers --- pokemontools/crystal.py | 15 --------------- pokemontools/helpers.py | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pokemontools/crystal.py b/pokemontools/crystal.py index 753095a..6f09274 100644 --- a/pokemontools/crystal.py +++ b/pokemontools/crystal.py @@ -6785,21 +6785,6 @@ def to_asm(some_object, use_asm_rules=False): asm += "\n; " + hex(last_address) return asm -def flattener(x): - "flattens a list of sublists into just one list (generator)" - try: - it = iter(x) - except TypeError: - yield x - else: - for i in it: - for j in flattener(i): - yield j - -def flatten(x): - "flattens a list of sublists into just one list" - return list(flattener(x)) - def get_dependencies_for(some_object, recompute=False, global_dependencies=set()): """ calculates which labels need to be satisfied for an object diff --git a/pokemontools/helpers.py b/pokemontools/helpers.py index e2f62e0..42cec87 100644 --- a/pokemontools/helpers.py +++ b/pokemontools/helpers.py @@ -12,3 +12,18 @@ def grouper(some_list, count=2): given: [1, 2, 3, 4] returns: [[1, 2], [3, 4]]""" return [some_list[i:i+count] for i in range(0, len(some_list), count)] + +def flattener(x): + "flattens a list of sublists into just one list (generator)" + try: + it = iter(x) + except TypeError: + yield x + else: + for i in it: + for j in flattener(i): + yield j + +def flatten(x): + "flattens a list of sublists into just one list" + return list(flattener(x)) -- cgit v1.2.3