Created
March 24, 2016 19:22
-
-
Save hltbra/b6bfe9baae0afa77f978 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from galaxy import Galaxy | |
G = Galaxy([1,2,3,4,5,6]) # creates 6 universes | |
G.assert_(lambda x: x > 3) # destroys universes 1,2,3 | |
G.assert_(lambda x: x < 6) # destroys universe 6 | |
print(G.all()) | |
print(G.any()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Inspired by https://github.com/karldray/quantum | |
Create by hltbra | |
""" | |
import random | |
class Galaxy(object): | |
def __init__(self, universes): | |
self._universes = universes | |
def assert_(self, cond): | |
new_universes = [] | |
for universe in self._universes: | |
if cond(universe): | |
new_universes.append(universe) | |
self._universes = new_universes | |
def any(self): | |
return random.choice(self._universes) | |
def all(self): | |
return self._universes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment