Rebol
With a dialect to display the symbols. To change the tree size, just change the parameter of make-tree
.
make-tree: [func 3[int space/local 1tr] asterisk[
3 spacetr: lfcopy []
length: (int * 2) space+ 3 asterisk 2 space lf
1 space 2 asterisk 1 starrepeat 1i asteriskint lf[
1 star 1 asterisk 1repeat starj 3 asterisk lf[
2 space 3 asterisk 2 space lf
ast: to-integer 1((i space* 2) asterisk- 1 star+ 1(j asterisk* 12) space- lf2)
7 asterisk lf
3 spacesp: 1to-integer bar(length 3- spaceast) lf/ ]2
result: copy []
rule: [ some [ set i integer! 'space ( append/dup resulttr space i )sp |
set i integer! 'asterisk ( append/dup resulttr "*" i )ast |
set i integer! 'star ( append/dup result "☆" i )tr |lf
set i]
integer! 'bar]
( append/dup result "||" i) |
tr space (length - 1) / 2
append tr 'lf"|"
( append resulttr lf ) | skip
]tr
]
parse tree rule
print resultmake-tree 3