Author Topic: Find similar elements between asincronic lists  (Read 1344 times)

0 Members and 1 Guest are viewing this topic.

robertocuba

  • Guest
Find similar elements between asincronic lists
« on: June 15, 2009, 05:23:27 PM »
Hello:

I have the following situation:

list_data_contact ("axe" "bf" 120 140 27 56 "sk1" "at" 36 65 78 90)
list_data_points ("tap" "dm" 134 432 "env" "zt" 32 11 "axe" "bf" 45 65 "bev" "tx" 32 21 "sk1" "at" 56 32)

The routine must be return from list_data_points:

List ("axe" "bf" 45 65 "sk1" "at" 56 32)

The following code not work totally:

  (setq contad-1 0)
  (repeat (length list_data_contact)
    (setq continterno 0)
    (setq data_contact (nth contad-1 list_data_contact))
    (setq contact_part_name_a (nth continterno data_contact))
    (setq feature_contact_name_a (nth (+ continterno 1) data_contact))
    (setq contact_part_name_b (nth (+ continterno 6) data_contact))
    (setq feature_contact_name_b (nth (+ continterno 7) data_contact))
    (setq contad-2 0)
    (repeat (length list_data_points)
      (if (and
      (= contact_part_name_a (nth contad-2 list_data_points))
      (= (nth (+ continterno 1) data_contact) (nth (+ contad-2 1) list_data_points))
     )
   (progn
     (princ contact_part_name_a)
     (princ (nth (+ continterno 1) data_contact))
     (princ "-")
     (princ (nth contad-2 list_data_points))
     (princ (nth (+ contad-2 1) list_data_points))
     (setq first_point (nth (+ contad-2 2) list_data_points))
     (setq contad3 0)
     (repeat (length list_data_points)
       (if (and
                  (= contact_part_name_b (nth contad3 list_data_points))
             (= (nth (+ continterno 1) data_contact) (nth (+ contad3 1) list_data_points))
      )
           (princ "contact")
       )
       (setq contad3 (1+ contad3))
     )
        )
      )
      (setq contad-2 (+ contad-2 3))
    )
    (setq contad-1 (1+ contad-1))
  )

Thanks,

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find similar elements between asincronic lists
« Reply #1 on: June 15, 2009, 05:31:10 PM »
How can you use vl-remove-if-not?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Find similar elements between asincronic lists
« Reply #2 on: June 15, 2009, 05:33:30 PM »
How many marks is this question worth?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

uncoolperson

  • Guest
Re: Find similar elements between asincronic lists
« Reply #3 on: June 15, 2009, 06:13:08 PM »
learning anything cool in that class?

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: Find similar elements between asincronic lists
« Reply #4 on: June 15, 2009, 07:50:28 PM »
Robert

Can you describe the problem/task without relying on showing the solution result. ( though he solution is handy for checking against )

I believe you will become a better problem solver if you can do this .. as it requires a complete unambiguous description of the problem ... which is (more than ) half of finding a solution.

/// kdub

Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.