L-system: Difference between revisions

Content added Content deleted
m (Quackery solution moved into correct alphabetical order)
Line 242: Line 242:
</syntaxhighlight>{{out}}
</syntaxhighlight>{{out}}
[[File:Kochsnowflakefractal.png|thumb|center|alt=fractal image|Koch Snowflake]]
[[File:Kochsnowflakefractal.png|thumb|center|alt=fractal image|Koch Snowflake]]

=={{header|Phix}}==
Just the generic part:
<syntaxhighlight lang="phix">
function lindenmayer(string s, sequence rules, integer count)
sequence {chars, reps} = columnize(rules)
for i=1 to count do
string nxt = ""
for c in s do
integer k = find(c,chars)
nxt &= iff(k?reps[k]:c)
end for
s = nxt
end for
return s
end function
</syntaxhighlight>
Invoke using eg <code><nowiki>lindenmayer("I",{{'I',"M"},{'M',"MI"}},5)</nowiki></code> which yields "MIMMIMIM"


=={{header|Quackery}}==
=={{header|Quackery}}==
Line 278: Line 296:
<pre>Rabbits: 5
<pre>Rabbits: 5
Kittens: 3</pre>
Kittens: 3</pre>

=={{header|Phix}}==
Just the generic part:
<syntaxhighlight lang="phix">
function lindenmayer(string s, sequence rules, integer count)
sequence {chars, reps} = columnize(rules)
for i=1 to count do
string nxt = ""
for c in s do
integer k = find(c,chars)
nxt &= iff(k?reps[k]:c)
end for
s = nxt
end for
return s
end function
</syntaxhighlight>
Invoke using eg <code><nowiki>lindenmayer("I",{{'I',"M"},{'M',"MI"}},5)</nowiki></code> which yields "MIMMIMIM"


=={{header|Raku}}==
=={{header|Raku}}==