Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
L-system
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Example 2: fractal (binary) tree=== * '''variables''' : 0, 1 * '''constants''': "[", "]" * '''axiom''' : 0 * '''rules''' : (1 β 11), (0 β 1[0]0) The shape is built by [[recursion|recursively]] feeding the axiom through the production rules. Each character of the input string is checked against the rule list to determine which character or string to replace it with in the output string. In this example, a '1' in the input string becomes '11' in the output string, while '<nowiki>[</nowiki>' remains the same. Applying this to the axiom of '0', one gets: {| |- | axiom: || 0 |- | 1st recursion: || 1<nowiki>[0]</nowiki>0 |- | 2nd recursion: || <nowiki>11[1[0]0]1[0]0</nowiki> |- | 3rd recursion: || <nowiki>1111[11[1[0]0]1[0]0]11[1[0]0]1[0]0</nowiki> |- | ... |} It can be seen that this string quickly grows in size and complexity. This string can be drawn as an image by using [[turtle graphics]], where each symbol is assigned a graphical operation for the turtle to perform. For example, in the sample above, the turtle may be given the following instructions: * 0: draw a [[line segment]] ending in a leaf * 1: draw a line segment * <nowiki>[</nowiki>: push position and angle, turn left 45 degrees * <nowiki>]</nowiki>: pop position and angle, turn right 45 degrees The push and pop refer to a [[LIFO (computing)|LIFO]] stack (more technical grammar would have separate symbols for "push position" and "turn left"). When the turtle interpretation encounters a '<nowiki>[</nowiki>', the current position and angle are saved, and are then restored when the interpretation encounters a '<nowiki>]</nowiki>'. If multiple values have been "pushed," then a "pop" restores the most recently saved values. Applying the graphical rules listed above to the earlier recursion, one gets: {{Gallery |width=150 |File:Graftal0.png|Axiom |File:Graftal1.png|First recursion |File:Graftal2.png|Second recursion |File:Graftal3.png|Third recursion |File:Graftal4.png|Fourth recursion |File:Graftal7.png|Seventh recursion, scaled down ten times }}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
L-system
(section)
Add topic