A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
18
Task/Loops-Do-while/Tcl/loops-do-while-1.tcl
Normal file
18
Task/Loops-Do-while/Tcl/loops-do-while-1.tcl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
proc do {body keyword expression} {
|
||||
if {$keyword eq "while"} {
|
||||
set expression "!($expression)"
|
||||
} elseif {$keyword ne "until"} {
|
||||
return -code error "unknown keyword \"$keyword\": must be until or while"
|
||||
}
|
||||
set condition [list expr $expression]
|
||||
while 1 {
|
||||
uplevel 1 $body
|
||||
if {[uplevel 1 $condition]} {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
set i 0
|
||||
do {puts [incr i]} while {$i % 6 != 0}
|
||||
3
Task/Loops-Do-while/Tcl/loops-do-while-2.tcl
Normal file
3
Task/Loops-Do-while/Tcl/loops-do-while-2.tcl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
package require control
|
||||
set i 0; control::do {puts [incr i]} while {$i % 6 != 0}
|
||||
set i 0; control::do {puts [incr i]} until {$i % 6 == 0}
|
||||
5
Task/Loops-Do-while/Tcl/loops-do-while-3.tcl
Normal file
5
Task/Loops-Do-while/Tcl/loops-do-while-3.tcl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
set i 0
|
||||
while true {
|
||||
puts [incr i]
|
||||
if {$i % 6 == 0} break
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue