We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Functions and Fractals - Recursive Trees - Bash!
Functions and Fractals - Recursive Trees - Bash!
Sort by
recency
|
154 Discussions
|
Please Login in order to post a comment
Kind of sad this is not a valid answer but i get it, it is a really inefficient solution
ITERATIVE version (ultra-compact)
it's messy but it works D:
!/bin/bash
Define the base empty row
base_str="________________________________________________________________________________________________" declare -a str_arr
Read input level
read level
Recursive function to draw fractal tree
draw_fractal() { local current_level=2 local pos=4
}
Initialize the grid with underscores (_)
for ((i = 0; i < 63; i++)); do str_arr[base_str done
Start drawing from the bottom center
draw_fractal 0 16 49 0
Print the grid from bottom to top
for ((i = 62; i >= 0; i--)); do echo "${str_arr[i]}" done