Jump to content

L-system: Difference between revisions

No change in size ,  1 month ago
m
Quackery solution moved into correct alphabetical order
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}}==
1,496

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.