L-system: Difference between revisions
m
Quackery solution moved into correct alphabetical order
m (→{{header|Quackery}}: tidy up) |
m (Quackery solution moved into correct alphabetical order) |
||
Line 242:
</syntaxhighlight>{{out}}
[[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}}==
Line 278 ⟶ 296:
<pre>Rabbits: 5
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}}==
|