+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Junior Member
    Using
    AutoCAD 2016
    Join Date
    Feb 2016
    Posts
    14

    Smile add tow list in one list

    Registered forum members do not see this ad.

    Hello everybody,
    i have tow list :
    list1 = (x1 x2 x3 x4 x5 x6 x7 .....)
    list 2 =(y1 y2 y3 y4 y5 y6 y7 .....)
    and i want to convert tow list to :
    list = ((x1 y1)(x2 y2)(x3 y3)(x4 y4)(x5 y5) .....)

    how can i do this??

    Thanks in advance

  2. #2
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    313

    Default

    Code:
    (mapcar '(lambda (r j) (list r j)) '(x1 x2 x3 x4 x5 x6 x7) '(y1 y2 y3 y4 y5 y6 y7))

  3. #3
    Junior Member
    Using
    AutoCAD 2016
    Join Date
    Feb 2016
    Posts
    14

    Default

    thank you ronjonp, But it may be more than x7 and y7 ,,,,and I know that the number of two lists is equal,,I entered these codes but i get error :

    (mapcar '(lambda (r j) (list r j)) '(list1) '(list2))

  4. #4
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    313

    Default

    Quote Originally Posted by amir0914 View Post
    thank you ronjonp, But it may be more than x7 and y7 ,,,,and I know that the number of two lists is equal,,I entered these codes but i get error :

    (mapcar '(lambda (r j) (list r j)) '(list1) '(list2))
    Take the ' off of your lists.
    Code:
    (setq list1 '("A" "B" "C" "D" "E" "F")
          list2 '(1 2 3 4 5 6)
    )
    (mapcar '(lambda (r j) (list r j)) list1 list2)

  5. #5
    Junior Member
    Using
    AutoCAD 2016
    Join Date
    Feb 2016
    Posts
    14

    Default

    Thank you very much ronjonp, great, my problem has been resolved
    excuse me for my poor english.

  6. #6
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    313

    Default

    Quote Originally Posted by amir0914 View Post
    Thank you very much ronjonp, great, my problem has been resolved
    excuse me for my poor english.
    Glad to help

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,226

    Default

    It could be reduced to:
    Code:
    (setq list1 '("A" "B" "C" "D" "E" "F")
          list2 '(1 2 3 4 5 6)
    )
    (mapcar 'list list1 list2)
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  8. #8
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    979

    Default

    Everytime I use (mapcar 'list ... ) in my code it reminds me of Lee, since the guide he gave me.

  9. #9
    Junior Member
    Using
    AutoCAD 2016
    Join Date
    Feb 2016
    Posts
    14

    Default

    Quote Originally Posted by Lee Mac View Post
    It could be reduced to:
    Code:
    (setq list1 '("A" "B" "C" "D" "E" "F")
          list2 '(1 2 3 4 5 6)
    )
    (mapcar 'list list1 list2)
    thank you lee mac, Your code is brief and perfect.

  10. #10
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    313

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Lee Mac View Post
    It could be reduced to:
    Code:
    (setq list1 '("A" "B" "C" "D" "E" "F")
          list2 '(1 2 3 4 5 6)
    )
    (mapcar 'list list1 list2)
    I like it!

Similar Threads

  1. need help with count list if list mach
    By plecs in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 11th Nov 2014, 07:49 am
  2. List of the file list (only names) copy to excel
    By wimal in forum AutoCAD General
    Replies: 4
    Last Post: 3rd Jul 2013, 11:53 am
  3. generate part-list/order-list in autocad 2011LT
    By Borken in forum AutoCAD Beginners' Area
    Replies: 7
    Last Post: 12th Jul 2012, 09:39 am
  4. write a list into text file and return back as list
    By muthu123 in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 21st Dec 2009, 04:31 pm
  5. Change popup list contents from one list to another
    By The Buzzard in forum AutoLISP, Visual LISP & DCL
    Replies: 9
    Last Post: 4th Mar 2009, 05:22 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts