Author Topic: naming consecutive lists in a loop  (Read 1113 times)

0 Members and 1 Guest are viewing this topic.

Denzuki

  • Guest
naming consecutive lists in a loop
« on: September 14, 2015, 05:10:23 PM »
How would I go about creating a loop that creates a new list but also creates AND renames the new list as it creates it.

the results are extracted from original lists and would look like this:

list 3 (r3-d1, r3-d2, r3-d3, .....r3-dx)
list 4 (r4-d1, r4-d2, r2-d3, .....r4-dx)
list 5 (r5-d1, etc......

Also, it must continue until it evaluates all items in each list and then resets so as to not continue to add duplication to the list.

thanks

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: naming consecutive lists in a loop
« Reply #1 on: September 14, 2015, 05:35:41 PM »
This?
Code - Auto/Visual Lisp: [Select]
  1. (setq dns '("d1" "d2" "d3" "d4" "d5")
  2.       lst '("r1" "r2" "r3" "r4" "r5")
  3. )
  4.  
  5. _$ (mapcar '(lambda ( x ) (mapcar '(lambda ( y ) (strcat x "-" y)) dns)) lst)
  6. (
  7.     ("r1-d1" "r1-d2" "r1-d3" "r1-d4" "r1-d5")
  8.     ("r2-d1" "r2-d2" "r2-d3" "r2-d4" "r2-d5")
  9.     ("r3-d1" "r3-d2" "r3-d3" "r3-d4" "r3-d5")
  10.     ("r4-d1" "r4-d2" "r4-d3" "r4-d4" "r4-d5")
  11.     ("r5-d1" "r5-d2" "r5-d3" "r5-d4" "r5-d5")
  12. )