L-system: Difference between revisions

Added Python
(Added various BASIC dialects (Applesoft BASIC, BASIC256, Chipmunk Basic, GW-BASIC, MSX Basic, QBasic, QB64, XBasic and Yabasic))
(Added Python)
Line 474:
Invoke using eg <code><nowiki>lindenmayer("I",{{'I',"M"},{'M',"MI"}},5)</nowiki></code> which yields "MIMMIMIM"
 
=={{header|QuackeryPython}}==
{{works with|Python|3.x}}
{{trans|FreeBASIC}}
<syntaxhighlight lang="python">#! /usr/bin/env python3
 
def lindenmayer(s, rules, count):
for i in range(count):
print(s)
nxt = ""
for c in s:
found = False
for j in range(0, len(rules), 2):
if c == rules[j]:
rep = rules[j + 1]
found = True
break
nxt += rep if found else c
s = nxt
 
rules = ["I", "M", "M", "MI"]
lindenmayer("I", rules, 5)</syntaxhighlight>
{{out}}
<pre>I
M
MI
MIM
MIMMI</pre>
 
=={{header|Quackery}}==
This solution reproduces the method used in other, pre-existing, tasks including [[Cantor set#Quackery|Cantor set]], [[Hilbert curve#Quackery|Hilbert curve]], [[Padovan sequence#Quackery|Padovan sequence]], [[Peano curve#Quackery|Peano curve]], [[Sierpinski curve#Quackery|Sierpinski curve]], and [[Sierpinski square curve#Quackery|Sierpinski square curve]].
 
2,169

edits