Created
August 6, 2019 08:31
-
-
Save dongho-jung/97788859dea1fe852c24bc8978a6c443 to your computer and use it in GitHub Desktop.
this function spew out next L-system result
This file contains 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
def l_system_gen(init, rule): | |
x = init | |
table = str.maketrans(rule) | |
while True: | |
yield x | |
x = x.translate(table) | |
l_system = l_system_gen('AB', {'A':'AB', 'B': 'A'}) | |
print(next(l_system)) | |
print(next(l_system)) | |
print(next(l_system)) | |
print(next(l_system)) | |
# ... cool isn't it? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment