Skip to content

Instantly share code, notes, and snippets.

@dongho-jung
Created August 6, 2019 08:31
Show Gist options
  • Save dongho-jung/97788859dea1fe852c24bc8978a6c443 to your computer and use it in GitHub Desktop.
Save dongho-jung/97788859dea1fe852c24bc8978a6c443 to your computer and use it in GitHub Desktop.
this function spew out next L-system result
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