19/03/15 01:34:55.02 4EriVrie.net
>>686 Squeak Smalltalk
| sp fn |
sp := $-. "sp := Character space."
fn := [:n |
| tree |
tree := [:lines :count |
(lines collectWithIndex: [:line :idx |
line, (String new: idx - 1 * 2 withAll: sp), line
]), lines
].
(((1 to: n) inject: #('木') into: tree) collectWithIndex: [:line :idx |
(String new: idx - 1 withAll: sp), line
]) reversed asStringWithCr
].
fn value: 0. "=>
'木' "
fn value: 1. "=>
'-木
木木' "
fn value: 2. "=>
'---木
--木木
-木--木
木木木木' "