L-system: Difference between revisions
Content deleted Content added
added RPL |
Thundergnat (talk | contribs) m →{{header|Raku}}: Add a Raku example |
||
Line 214: | Line 214: | ||
</syntaxhighlight> |
</syntaxhighlight> |
||
Invoke using eg <code><nowiki>lindenmayer("I",{{'I',"M"},{'M',"MI"}},5)</nowiki></code> which yields "MIMMIMIM" |
Invoke using eg <code><nowiki>lindenmayer("I",{{'I',"M"},{'M',"MI"}},5)</nowiki></code> which yields "MIMMIMIM" |
||
=={{header|Raku}}== |
|||
L-system functionality as a Role that may be mixed in to a scalar. |
|||
<syntaxhighlight lang="raku" line># L-system functionality |
|||
role Lindenmayer { |
|||
has %.rules; |
|||
method succ { |
|||
self.comb.map( { %!rules{$^c} // $c } ).join but Lindenmayer(%!rules) |
|||
} |
|||
} |
|||
# Testing |
|||
my $rabbits = 'I' but Lindenmayer({I => 'M', M => 'MI'}); |
|||
.say for $rabbits++ xx 6;</syntaxhighlight> |
|||
{{out}} |
|||
<pre>I |
|||
M |
|||
MI |
|||
MIM |
|||
MIMMI |
|||
MIMMIMIM</pre> |
|||
Also see:</br> |
|||
[[Dragon_curve#Raku]]</br> |
|||
[[Hilbert_curve#Raku]]</br> |
|||
[[Koch_curve#Raku]]</br> |
|||
[[Peano_curve#Raku]]</br> |
|||
[[Penrose_tiling#Raku]]</br> |
|||
[[Sierpinski_curve#Raku]]</br> |
|||
[[Sierpinski_arrowhead_curve#Raku]]</br> |
|||
[[Sierpinski_square_curve#Raku]]</br> |
|||
among others... |
|||
=={{header|RPL}}== |
=={{header|RPL}}== |