V , 54 , 50 octets
¬ ~9ñ9É 11|á
ñ2ñ20lá
ñ$18é 9ñ^y|Ehé
Pf xxywk$hP>ñd
Essayez-le en ligne!
Contrairement à l'habitude, ce programme ne contient aucun caractère non imprimable.
Explication:
¬ ~ " Insert the entire printable ASCII range
9ñ ñ " 9 times:
9É " Insert 9 spaces at the beginning of this line
11| " Move to the 11'th column on this line
á<CR> " And append a newline after the 11'th column
Maintenant, le tampon ressemble à ceci:
!
"#
$%
&'
()
*+
,-
./
01
23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
Maintenant, nous construisons le milieu:
2ñ ñ " Two times:
20l " Move 20 characters to the right (because 'l' == 'right', duh)
á<CR> " Append a newline
Voici où ça devient un peu bizarre.
$ " Move to the end of this line
18é " Insert 18 spaces before the last character
9ñ " Repeat the following 9 times:
^ " Move to the first non-whitespace character
y| " Yank all the whitespace before the current character.
" We'll call this the "Leading whitespace register"
E " Move to the end of the current WORD (up to before a space)
h " Move back one character
é<CR> " And insert a newline before the current character
P " Paste the leading whitespace for indentation
f " Move forward to a space
xx " Delete two characters
" (Note how we are inbetween the two bottom branches right now)
yw " Yank everything upto the next branch (all spaces)
" We'll paste this on the line up so that we can yank it again later
" To keep track of how far apart the branches are
k$ " Move up a line and to the end of that line
hP " Move back a character and paste the whitespace we yanked
> " Indent this line by one space
ñ " End the loop
Voici une note importante. La >commande est en fait un opérateur , ce qui signifie qu'elle ne fait rien sans argument, le texte sur lequel opérer. Par exemple,
>_ "Indent the current line
>> "Indent the current line
>j "Indent the current and next line
>G "Indent every line
Mais puisque cette commande est dans une boucle, nous pouvons sauvegarder un caractère en ne donnant pas d'opérateur. À la fin d'une boucle, si un opérateur est en attente, il remplira_ (la ligne actuelle) comme argument implicitement.
Maintenant, j'admets que cette boucle est un peu bizarre, et il peut être difficile de garder une trace de ce à quoi tout le texte devrait ressembler à un moment donné. Vous pouvez donc utiliser ce programme plus simple pour voir à quoi il ressemblera après N boucles.
Si vous le définissez sur 9, vous pouvez voir que nous avons un peu de texte supplémentaire à supprimer. (Juste la ligne actuelle).
Nous supprimons donc la ligne actuelle avec dd. Mais attendez! Vous savez comment j'ai dit que les opérateurs doivent prendre un argument qui est parfois implicitement rempli? Les arguments sont également implicitement remplis à la fin du programme. Donc plutôt que ddou d_(qui sont équivalents), nous pouvons simplement det laisser V remplir le _pour nous.