Jump to content
Sign in to follow this  
JAMIE

compare two list and display the different elemts

Recommended Posts

hi all,

set a "1 2 3 "

set b " 4 1 3 8 2"

 i need to compare these two lists ...not on the basis of order of arrangement only difference 

output i need is  4  8

 

i tried using using *markintersection its not working

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

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?

 

Share this post


Link to post
Share on other sites
1 hour ago, tinh 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 à :D

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...