1
$\begingroup$

I want to make a list from other list:

   list1={A,B,C,S}; list2=Table[i,{i,1,end}];

Then my list three will be i->jwhere i are elements of list2 and j the elements of list 1 (repeated until end )

$\endgroup$
  • 1
    $\begingroup$ Thread[list2 -> list1]? $\endgroup$ – J. M. is away Apr 2 '18 at 0:55
  • $\begingroup$ Try do show your own code effort and further explain where the variable "end" implies $\endgroup$ – Jose Enrique Calderon Apr 2 '18 at 3:33
2
$\begingroup$

Assuming that the lists can be of unequal Length, Length[list1] >= Length[list2], and list2 cycles as required

list1 = {"A", "B", "C", "S"};

list2 = Range[3];

Thread[list1 -> PadRight[list2, Length[list1], list2]]

(* {"A" -> 1, "B" -> 2, "C" -> 3, "S" -> 1} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.