vijayP Posted May 30, 2014 Share Posted May 30, 2014 (edited) What should be the Logic to find out duplicate number from a nubmer series. like 110 111 112 113 114 111 110 111 115 116 along with there (x,y) For Ex. 110 is repeated 2 times ("110" ("1057.03 475.00" "821.46 436.99")) ;;("num" ("1st x y" "2nd x y")) 111 is repeated 3 times ("111" ("614.88 467.76" "422.80 605.32" "1524.55 420.70")) ;;("num" ("1st x y" "2nd x y" "3rd x y")) so that we can put them in 2 tile list box. In first tile num and in second tile its all x y. Edited May 30, 2014 by vijayP Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 30, 2014 Share Posted May 30, 2014 I can't see that 110 and 111 are repeated in your posted list ! Can you be more specific to the point ? Thanks Quote Link to comment Share on other sites More sharing options...
vijayP Posted May 30, 2014 Author Share Posted May 30, 2014 110 111 112 113 114 111 110 111 115 116 Thanks for reply Tharwat. see now. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 30, 2014 Share Posted May 30, 2014 This ... ? (setq l '(110 111 112 113 114 111 110 111 115 116)) (foreach i l (if (not (member i lst)) (setq lst (cons i lst)))) (reverse lst) Quote Link to comment Share on other sites More sharing options...
MSasu Posted May 30, 2014 Share Posted May 30, 2014 I believe that concerned list is the enumeration from OP's statement, Tharwat; below he/she just provided examples of items. VijayP, to list the duplicates just parse your list using FOREACH and store each element into a new one; use MEMBER to check if current element is already there - if yes, then you have a duplicate. Quote Link to comment Share on other sites More sharing options...
vijayP Posted May 30, 2014 Author Share Posted May 30, 2014 Tharwat; your code is returning list without duplicate but i need all duplicate and their x y. so that we can find them Msasu; any example code? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted May 30, 2014 Share Posted May 30, 2014 Can you be more specific to the point ? Tharwat; your code is returning list without duplicate but i need all duplicate and their x y. so that we can find them If you do not give a clear example of what you are after , people would keep on guessing and posting unneeded codes and maybe no one would follow your thread . This is just for your information . Quote Link to comment Share on other sites More sharing options...
vijayP Posted May 30, 2014 Author Share Posted May 30, 2014 find out duplicate numbers from a nubmer series.like 110 111 112 113 114 111 110 111 115 116 along with there (x,y) Tharwat; please see post #1 again Quote Link to comment Share on other sites More sharing options...
hmsilva Posted May 30, 2014 Share Posted May 30, 2014 As a "Demo"... (setq lst '(("110" ("1.6 3.3" "2.0 3.5" "1.8 2.9")) ("111" ("1.5 3.2" "2.0 3.5" "1.8 2.9")) ("111" ("1.5 3.2" "2.0 3.5" "1.8 2.9")) ("112" ("1.8 3.8" "2.8 3.8" "1.0 2.0")) ("112" ("1.8 3.8" "2.8 3.8" "1.0 2.0")) ("113" ("1.5 3.2" "2.0 3.5" "1.8 2.9")) ("114" ("1.0 3.0" "2.6 3.6" "1.6 2.6")) ("114" ("1.0 3.0" "2.6 3.6" "1.6 2.6")) ) ) (foreach x lst (if (member x tmplst) (setq dup-lst (cons x dup-lst));; dup-lst will retain all the duplicate ) (setq tmplst (cons x tmplst)) ) HTH Henrique Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.