Execute HQ9+/Tcl: Difference between revisions

m
Fixed syntax highlighting.
m (Add SMW link)
m (Fixed syntax highlighting.)
 
Line 4:
{{works with|Tcl|8.4}}
<br clear=right>
===Interpreter===
<langsyntaxhighlight lang="tcl">set d [read [expr {$argc?[open [lindex $argv 0]]:"stdin"}]]
for {set i [set a 0]} {$i<[string len $d]} {incr i} {
switc\u0068 -- [string index [string tolower $d] $i] \u0068 {
Line 19:
}
} \x2b {incr a}
}</langsyntaxhighlight>
===Compiler===
To be fair, this compiler then immediately executes the code. Replace the <code>eval</code> with <code>puts</code> to see what it generates.
<langsyntaxhighlight lang="tcl">set d [read [expr {[set a $argc]?[open [lindex $argv [set a 0]]]:"stdin"}]]
eval [string map [list \u0068 {puts "\u0048ello, world!";} q \
[list puts -nonewline $d]\n \071 {for {set b [expr 100-1]} 1 {} {
Line 32:
if {$b} {puts ""} else break
};} \x2b {incr a;}
] [regsub -all {[\u0000-*,-8:-gi-pr-\uffff]*} $d {}]]</langsyntaxhighlight>
9,476

edits