compare two list and display the different elemts
Answers
-
Hi
*markintersection is used for hm entities only.
a proc like this
proc ::ldiff {list1 list2} {
set result {}
foreach item $list1 {if {[lsearch $list2 $item]==-1} {lappend result $item}}
set result
}
#now call
ldiff $b $a
0 -
hi tinh ,
ya this is working....in case if we have
set a '1 2 3'
set b '1 3 4'
out put
2 4
in this case we have to loop both the lists and append in a separate list . ryt?
0 -
just try it and show us your results
0 -
Altair Forum User said:
just try it and show us your results
chào Tĩnh, mình mới học về hypermesh và đang muốn viết script cho hypermesh, bạn học về hypermesh à /emoticons/default_biggrin.png' srcset='/emoticons/biggrin@2x.png 2x' title=':D' width='20' />
0 -
hi tinh,
in the code which u have written ,what does set result does.?(after the for loop)
0 -
it returns result.
i think it is not neccessary. because lappend will return it
could you remove it and try?
0 -
no no, it is needed. because sometimes lsearch not found item, it will return emptied string
0