0
$\begingroup$

I have a list of elements, which I want to sort according to the even/odd numbered positions of elements. Basically creating two lists out of one, respectively having elements placed at even/odd positions in the original list.

For example, A = {a, b, c, d, e, f}; should split into A1 = {a, c, e} and A2 = {b, d, f}.

Will appreciate any help.

$\endgroup$
  • 3
    $\begingroup$ {A1, A2} = Transpose@Partition[A, 2] $\endgroup$ – LouisB Jan 4 at 10:37
2
$\begingroup$
A1 = A[[;; ;; 2]];
A2 = A[[2 ;; ;; 2]];
| improve this answer | |
$\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.