Pop-Up Thingie
Sidebar
>>> Magnum BBS <<<
Home
Forum
Files
Dark
Log in
Username
Password
Sidebar
Forum
Usenet
COMP.LANG.TCL
Why join result of lreplace when it will be interpreted as a list anywa
From
clt.to.davebr@dfgh.net
@21:1/5 to
All
on Mon Jul 25 19:11:55 2022
tkcon appears to create
proc lremove {args} {
array set opts {-all 0 pattern -exact}
while {[string match -* [lindex $args 0]]} {
switch -glob -- [lindex $args 0] {
-a* { set opts(-all) 1 }
-g* { set opts(pattern) -glob }
-r* { set opts(pattern) -regexp }
-- { set args [lreplace $args 0 0]; break }
default {return -code error "unknown option \"[lindex $args 0]\""}
}
set args [lreplace $args 0 0]
}
set l [lindex $args 0]
foreach i [join [lreplace $args 0 0]] {
if {[set ix [lsearch $opts(pattern) $l $i]] == -1} continue
set l [lreplace $l $ix $ix]
if {$opts(-all)} {
while {[set ix [lsearch $opts(pattern) $l $i]] != -1} {
set l [lreplace $l $ix $ix]
}
}
}
return $l
}
which is useful. However I do not see why "join" is used in the foreach line:
foreach i [join [lreplace $args 0 0]] {
It appears to convert the list from lreplace to a string, which is then converted back to a list by foreach
What am I missing?
Dave B
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
Who's Online
System Info
Sysop:
Keyop
Location:
Huddersfield, West Yorkshire, UK
Users:
493
Nodes:
16 (
2
/
14
)
Uptime:
35:03:56
Calls:
9,740
Files:
13,741
Messages:
6,183,425