Version 0 of Code golf- ASCII keyboard

Updated 2016-12-24 17:26:29 by LAM

<LAM 24-12-2016>

sergiol proposes in your page an exercise of code golf: make an ascii keyboard (according to code golf page ). The result must be this:

____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ________ 
||` |||1 |||2 |||3 |||4 |||5 |||6 |||7 |||8 |||9 |||0 |||- |||= |||BS    ||
||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||______||
|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/______\|
 ________ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ 
||TAB   |||Q |||W |||E |||R |||T |||Y |||U |||I |||O |||P |||[ |||] |||\ ||
||______|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__||
|/______\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|
 _________ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ________ 
||CAPS   |||A |||S |||D |||F |||G |||H |||J |||K |||L |||; |||' |||ENTER ||
||_______|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||______||
|/_______\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/______\|
 ___________ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ___________ 
||SHIFT    |||Z |||X |||C |||V |||B |||N |||M |||, |||. |||/ |||SHIFT    ||
||_________|||__|||__|||__|||__|||__|||__|||__|||__|||__|||__|||_________||
|/_________\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/__\|/_________\|

I found this was an funny way to push the boundaries of tcl (and of my knowledge about it). For example, after this exercise i've learned(suffered) a lot about the delicate relationship among spaces and brackets.

This is my best anwser ...

* One line:

foreach z {S R M} w {set "regsub -all" "string map"} {interp alias {} $z {} {*}$w};foreach x {"`1234567890-=¿BS   ¿" "¿TAB  ¿QWERTYUIOP\[\]\\" "¿CAPS  ¿ASDFGHJKL;'¿ENTER¿" "¿SHIFT   ¿ZXCVBNM,./¿SHIFT   ¿"} {S h [M {\\ _ / _ | \ } [S g [M {||_ |/_  _|| _\\|} [M {||| \\|/} [S f [R {[^\n|]} [S b [M {|||| |||} [R {¿(\S+\s*)¿|(.)} $x {||\1\2 ||}]]] _ ]]]]]];puts $h\n$b\n$f\n$g}

* More readeable:

foreach z {S R M} w {set "regsub -all" "string map"} {
        interp alias {} $z {} {*}$w
}
foreach x {"`1234567890-=¿BS   ¿" \
                "¿TAB  ¿QWERTYUIOP\[\]\\" \
                "¿CAPS  ¿ASDFGHJKL;'¿ENTER¿" \
                "¿SHIFT   ¿ZXCVBNM,./¿SHIFT   ¿" } {
                  S h [M {\\ _ / _ | \ } \
                         [S g [M {||_ |/_  _|| _\\|} \
                          [M {||| \\|/} [S f \
                            [R {[^\n|]} [S b [M {|||| |||} \
                              [R {¿(\S+\s*)¿|(.)} $x {||\1\2 ||}]]] _ ]]
                            ]
                          ]
                         ]
                        ]
                  puts $h\n$b\n$f\n$g 
}