Groups
Sign in
Groups
comp.lang.tcl
Conversations
About
Send feedback
Help
info
Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Learn more
Why join result of lreplace when it will be interpreted as a list anyway?
36 views
Skip to first unread message
clt.to...@dfgh.net
unread,
Jul 25, 2022, 3:12:03 PM
7/25/22
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
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
0 new messages