[Question]
  [
## Background
*[Milking the deck](http://www.dictionaryofgambling.com/gambling_terms/poker/m/#milk_the_deck)* is the name given to the following card shuffling method:
1. 'Pinch' the deck to remove the top and bottom cards simultaneously. (With lots of imagination, this action resembles milking a cow.) This pair of cards forms the base of a new pile.
2. Repeat, adding each pair of cards to the top of the new pile, until the whole deck has been used.
**Example**
Suppose we start with a deck of six cards, `[1, 2, 3, 4, 5, 6]` (lower-indexed elements are nearer to the top). Let's milk the deck:
0. `old = [1, 2, 3, 4, 5, 6]`, `new = []`
1. Remove `[1, 6]`: `old = [2, 3, 4, 5]`, `new = [1, 6]`
2. Remove `[2, 5]`: `old = [3, 4]`, `new = [2, 5, 1, 6]`
3. Remove `[3, 4]`: `old = []`, `new = [3, 4, 2, 5, 1, 6]`
After milking, the deck is therefore ordered `[3, 4, 2, 5, 1, 6]`.
## Challenge
Your task in this [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge is to implement the milking operation on a given array and output/return the result. The input array will contain only positive integers, not necessarily distinct. If the input array contains an odd number of elements, then the last milking step transfers only one element (the last one remaining) from the input to the output array.
## Test cases
Input -> Output
```
[1, 2, 3, 4, 5, 6] -> [3, 4, 2, 5, 1, 6]
[1, 2, 3, 4, 5, 6, 7] -> [4, 3, 5, 2, 6, 1, 7]
[9, 7, 5, 3, 1, 2, 4, 6, 8, 10] -> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 1, 2, 1, 2] -> [2, 1, 1, 1, 2]
[] -> []
```
  
[Answer]
# [R](https://www.r-project.org/), ~~53~~ ~~50~~ 48 bytes
```
f=function(x,y=rev(x))if(c(y,F))c(f(y[-1]),y[1])
```
[Try it online!](https://tio.run/##K/qfm5mTbfs/zTatNC@5JDM/T6NCp9K2KLVMo0JTMzNNI1mjUsdNUzNZI02jMlrXMFZTpzIaSP5PLCpKrLQ1tDLjAhmgAeZq/gcA "R – Try It Online")
Repeatedly takes the bottom card & flips the deck.
[Answer]
# [R](https://www.r-project.org/), 36 bytes
```
function(x)rbind(rev(x),x)[-seq(!x)]
```
[Try it online!](https://tio.run/##K/qfm5mTbfs/rTQvuSQzP0@jQrMoKTMvRaMotQzI1qnQjNYtTi3UUKzQjP2fWFSUWGlraGXOBdKkAeZqQtiZeSWp6alFGgaamv8B "R – Try It Online")
Takes `integer(0)` (a length 0 integer vector) for empty input.
Stacks the reversed array onto itself, giving something like:
```
     [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]    7    6    5    4    3    2    1
[2,]    1    2    3    4    5    6    7
```
And then removes the first `n=length(x)` elements, going down the columns, then across the rows.
[Answer]
# [Haskell](https://www.haskell.org/), ~~38~~, 33 bytes
```
g(x:y)=f y++[x]
g x=x
f=g.reverse
```
[Try it online!](https://tio.run/##ZYxNCsIwFIT3OcUsW/oo/lStQo7gCUIWAZNYbGtJRdLTx5hAEdw8Zr5veHc1P3Tfh2ALf1lKbrBUlfCSWXjumeG2dvqt3azDoLoRHLcnAwY1XVFMrhtfqGHKiAABsSXsCHtCQzgQjjIJ@heE0@rOsSQadd41adHGuvn9kOX3rjQHGT4 "Haskell – Try It Online")
**-5 bytes thanks to @Zgarb.**
Very simple port of [Dominic van Essen's solution](https://codegolf.stackexchange.com/a/207460/42833). Go upvote theirs instead.
I was going to put this as a reference to compare to in [my other answer](https://codegolf.stackexchange.com/a/207467/42833), but figured it was more in the spirit of cgcc to submit twice.
[Answer]
# [Haskell](https://www.haskell.org/) with `-XParallelListComp`, ~~52~~ 49 bytes
```
f l=drop(length l)$id=<<[[x,y]|x<-reverse l|y<-l]
```
[Try it online!](https://tio.run/##ZYxLC4JAFIX3/YqzaKFwjR72Al21LWgZyCyGHHXo@mCUUPC3N5lCBG0u53zf4WayfihmaxNwGJuyclgVaZOB3bmOwyCIopY60beBZ9RTmVqB@y7wWNhc6gIh4nIG5LK6wKmMLhoskLgDAiJEK8KasCH4hC1hJ0ZB/4Kw/7rjUEY66Gnnj4vDUJe/Hyb5uV86BWFf94RlWlvvdpVGMis@67o5lXn1Bg "Haskell – Try It Online")
# Explanation
This is for my old answer. The only difference is that the riffling has been golfed from a call to `zip` and a flattening step to a parallel list comprehension and a flattening step.
This works by taking two copies of the input deck. You reverse the first copy, then riffle it with the second. Then remove as many cards as there were in the input deck, leaving behind the answer. In the code,
```
f l=drop(length l)$(\(x,y)->[x,y])=<<zip(reverse l)l
                   (\(x,y)->[x,y])=<<zip(reverse l)l  riffling
                                     zip                riffle
                                         reverse l      the reversed deck
                                                   l    the deck
                   (\(x,y)->[x,y])=<<                 flattening
    drop(length l)                                    removing
    drop                                                discard (from top)
         length l                                       length of input
```
The `flattening` portion does as follows. When riffled, the deck looks like `[(6,1),(5,2),(4,3),(3,4),(2,5),(1,6)]` (list of tuples). We "flatten it" to look like `[6,1,5,2,4,3,3,4,2,5,1,6]`.
I remain convinced that this approach might be shorter than the [port of Dominic van Essen's answer](https://codegolf.stackexchange.com/a/207469/42833). I think the `(\(x,y)->[x,y])` function can be shortened or removed, as well as the annoying use of `length`.
# Pointfree Haskell, 61 bytes
Just for fun; I initially thought it would be shorter.
```
foldr(pure tail).((\(x,y)->[x,y])=<<).(zip.reverse<*>id)<*>id
```
[Answer]
# [Perl 5](https://www.perl.org/) + `-p`, 33 bytes
```
$\=" $` $'".$\,$_=$1while/ (.+) /
```
[Try it online!](https://tio.run/##K0gtyjH9/18lxlZJQSVBQUVdSU8lRkcl3lbFsDwjMydVX0FDT1tTQf//f0MFIwVjBRMFUwWzf/kFJZn5ecX/dQsA "Perl 5 – Try It Online")
## Explanation
This approach utilises `-p` which allows work on input implicitly, by putting it in `$_` for each line of STDIN and implicitly `print`ing `$_` at the end of the program. `$\` is used as this magic variable is automatically `print`ed after the contents passed to `print`. The main body is a `while` loop that checks if `$_` `m//`atches `(.+)` (a space followed by one or more characters followed by another space), while `$_` does march (`m//` implicitly checks `$_` when not called via `=~`) `$\` is set to a space, the remaining string after the match (`$'`) followed by another space and the preceding string contents before the match (`$`` ), concatenated with the existing contents of `$\`. `$_` is then set to the matched string (excluding the spaces) which is captured in `$1`. At the end of the script, this leaves the central characters (either one or two depending on whether the list has an even or odd number of entries) in `$_`, which is implicitly `print`ed, followed by the content of `$\`, which contains a leading space and the rest of the list "milked".
[Answer]
# [Python 3](https://docs.python.org/3/), 36 bytes
```
M=lambda a:a and M(a[-2::-1])+a[-1:]
```
[Try it online!](https://tio.run/##bUy7CoMwANz9ihsTekKT@GgD/YR8gWRIcVBoYxCXfn2M0MXS4Y57cemzTUs0ObvHK7yfY0CwBXGEE2GotbW18vJSpLI@p3WOm3BiUNQ0bNiy81JW/3L2p@ZO9ERLGEIRmmiIjrgVe/35@A4OPjXF5B0 "Python 3 – Try It Online")
Uses Dominic van Essen's [approach](https://codegolf.stackexchange.com/a/207460/68261): repeatedly takes the bottom card and recurses on the reverse of the rest of the deck.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~9~~ ~~8~~ 7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
Âsø˜2äθ
```
-1 byte thanks to *@Neil*
[Try it online](https://tio.run/##yy9OTMpM/f//cFPx4R2n5xgdXnJux///0YY6CkY6CsY6CiY6CqY6CmY6CuaxAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/w03Fh3ecnmN0eMm5Hf91/kdHG@oY6RjrmOiY6pjF6iDzdMyBfEsdcyDbWAckbgIUs9AxNAArAwkAMZAdGwsA).
Or alternatively, a port of [*@DominicVanEssen*'s approach](https://codegolf.stackexchange.com/a/207460/52210) is **7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)** as well:
```
vRćˆ}¯R
```
[Try it online](https://tio.run/##yy9OTMpM/f@/LOhI@@m22kPrg/7/jzbUUTDSUTDWUTDRUTDVUTDTUTCPBQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfaXL/7KgI@2n22oPrQ/6r3Noy//oaEMdIx1jHRMdUx2zWB1kno45kG@pYw5kG@uAxE2AYhY6hgZgZSABIAayY2MB).
**Explanation:**
```
Â        # Bifurcate the (implicit) input-list (short for Duplicate & Reverse copy)
         #  i.e. [1,2,3,4,5,6,7] → [1,2,3,4,5,6,7] and [7,6,5,4,3,2,1]
 s       # Swap so the input-list is at the top again
         #  → [7,6,5,4,3,2,1] and [1,2,3,4,5,6,7]
  ø      # Zip/transpose the lists together to create pairs
         #  → [[7,1],[6,2],[5,3],[4,4],[3,5],[2,6],[1,7]]
   ˜     # Flatten it
         #  → [7,1,6,2,5,3,4,4,3,5,2,6,1,7]
    2ä   # Split it into 2 equal-sized parts
         #  → [[7,1,6,2,5,3,4],[4,3,5,2,6,1,7]]
      θ  # Pop and push just the last part
         #  → [4,3,5,2,6,1,7]
         # (after which it is output implicitly as result)
v        # Loop the (implicit) input-list amount of times:
         #   i.e. we'll loop 7 times for input [1,2,3,4,5,6,7]
 R       #  Reverse the list at the top of the stack,
         #  which will use the (implicit) input-list in the first iteration
         #   i.e. [1,2,3,4,5,6,7] → [7,6,5,4,3,2,1]
  ć      #  Extract head; pop and push remainder-list and first item separated
         #   → [6,5,4,3,2,1] and 7
   ˆ     #  Pop this first item, and add it to the global array
}¯       # After the loop: push the global array
         #  → [7,1,6,2,5,3,4]
  R      # Reverse it
         #  → [4,3,5,2,6,1,7]
         # (after which it is output implicitly as result)
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~65~~ ~~62~~ 60 bytes
```
i;f(c,z)int*c;{for(i=0;i||(i=z-=2)>0;)*c^=c[i--]^=*c^=c[i];}
```
[Try it online!](https://tio.run/##dVDdboIwFL4/T3HCsgTwYGxLwQ3xRZwmBmRrsqFBvEF5dnfKzzDL1gv6/Z2vLVnwnmX3u0kKN6PGM2XtZ8m1OFauSReJud14b4JUeutF4vnZLs02Jgi2u3TA26S9nyoec@3ovqqId2y8K2BXwqQrWjXJbGY8QOzShes85@gQD3CHl0ALUB/Of7T0cXQdU54uNb6iw@ledW2wsbSY4E/@rTxe6v9H2DnbkNMfbs/LxWabXgVJUhSSpqhNel3@0ikeHWWdF8KYUBMqQkEoCUPCiHDJdDEmw75jCNjv6GjrMAF4MmX2eckPuDrXuTnOP9Zd4mtvStdD/hndL8oFRfYFPZEUT0SRWEyM7zoRTdYBaO8CJSoMUWOEfockY4ER@NgvH/SQmVQfwk6bkj4oVsJBYc4KPJbHuGTRYsVMMhe4hBinJSCajzgGPeAIwg5pULyH8NhoG6JhQvI1pzynh9R4knUVX1vzs@Eb "C (gcc) – Try It Online")
The loop iterates backwards from the last - 1 element and swaps it with the first element.
Then it restarts iteration two elements backwards until finished.
Saved 3 using loop reset in loop check instead of recursion.
Saved 2 more because `i>0` check is no more needed.
Example
```
1 2 3 4 5 6 7 8 => 4 5 3 6 2 7 1 8
7           1
6.        7
5.      6
4.    5
3.  4
2 3 4 5 6 7 1 8
6       2
5     6
4.  5
3 4 5 6 2 7 1 8
5   3
4 5
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~11~~ 10 bytes
-1 byte thanks to @FryAmTheEggman
```
L&bay_Pbeb
```
port of [Dominic van Essen's solution](https://codegolf.stackexchange.com/questions/207456/hot-moo-shuffle-milk-an-array/207460#207460) to [Pyth](https://github.com/isaacg1/pyth).
[Try it online!](https://tio.run/##K6gsyfj/30ctKbEyPiApNany//9oQx0FIDKCkLH/8gtKMvPziv/rpgAA "Pyth – Try It Online")
## Explanation
```
L&bay_Pbeb
L              define function named y with argument b which returns
 &b            short circuiting and of b and
   a    eb     the last element of b appended to
    y          the return value of y when called on
     _         the reverse of
      Pb       b without its last element
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 6 bytes
```
ec2.i_
```
[Try it online!](https://tio.run/##K6gsyfj/PzXZSC8z/v//aEMdBSMdBWMdBRMdBVMdBTMdBfNYAA "Pyth – Try It Online")
Looking through the [Pyth documentation](https://github.com/isaacg1/pyth/blob/master/rev-doc.txt) reminded me of the interleave function `.i`, which is extremely useful here.
How it works:
* `.i`: Interleave the following two lists:
	+ `_`: The reversal of the input (implicit), and
	+ The input (implicit).
* `c2`: Split the result in half.
* `e`: Output the second half.
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 7 bytes
-4 bytes thanks to Ada
-3 bytes thanks to Bubbler
-1 byte thanks to ngn!
```
≢↓∘∊⌽,⍪
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v8/7VHbhEedix61TX7UMeNRR9ejnr06j3pX/X/UNxUok6ZgqGCkYKxgomCqYMaFRUzBHC5qqWAOFDEGy5oAZSwUDA2QtICEgRgu8qh3zX8A "APL (Dyalog Classic) – Try It Online")
Port of [Kevin Cruijssen's 05AB1E answer](https://codegolf.stackexchange.com/a/207458/75681) and [streetster's K solution](https://codegolf.stackexchange.com/a/207495/75681) - don't forget to upvote them!
[Answer]
# [Python 3](https://docs.python.org/3/), 45 bytes
```
M=lambda a:a and M(a[1:-1])+a[::len(a)-1or 1]
```
[Try it online!](https://tio.run/##bYzNCsIwHMPvPkWOLWbgf92XBR@hT1B6qExQmN0Yu/j0tYKXiYcEkl/I8truczI5u8sUn9cxItqiNMKp6MVWEvQxemunW1JRVzKvkJCX9ZE25ZQX1jRs2LILWh/@9ex35Ez0REsYQoiaaIiOGEo8/Xx8Bx/fkRLyGw "Python 3 – Try It Online")
Performs milking in the same procedure as specified.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 10 bytes
Same approach as [Dominic van Essen's answer](https://codegolf.stackexchange.com/a/207460/95594), so upvote that.
```
Ė|tT&k↔↰,T
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//8i0mpIQtexHbVMetW3QCfn/P9pQx0jHWMdEx1THLPZ/FAA "Brachylog – Try It Online")
```
Ė|tT&k↔↰,T
Ė          input is an empty list
 |         or
  tT       save the input's last element as T
    &      and
     k     the input without the last element
      ↔    reverse it
       ↰   recursively call this predicate
        ,T and append T 
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 14 bytes
```
Ｉ⮌Ｅθ§⎇﹪κ²θ⮌θ⊘κ
```
[Try it online!](https://tio.run/##Nco9C8IwEIDhv3LjBc7B78FJXOpQEHErHY7mQGlI7DUG/fVnEHy3F57hzjokDmYXfcSMJ54zXqWIzoItP3EiOOZz9PLGm2hk/WCb/CskHAlWjqCCv59c/YZDEY@j@3Uw67pllQRrgg3BlmBHsO97W5TwBQ "Charcoal – Try It Online") Link is to verbose version of code. Works by calculating the reverse of the first half of the flattened zip of the reversed list with itself. Explanation:
```
   θ            Input array
  Ｅ             Map over elements
       κ        Current index
      ﹪ ²       Modulo literal 2
         θ      Input array
     ⎇          If index was odd otherwise
          ⮌     Reverse of
           θ    Input array
    §           Indexed by
             κ  Current index
            ⊘   Halved
 ⮌              Reverse the result
Ｉ               Cast to string
                Implicitly print
```
[Answer]
# Brainfuck, 64 Bytes
```
,[>,]<[[->>+<<]<[<]>[-<+>]<[->>[>]>+<<[<]<]>>[[-<+>]>]<<]>>>[.>]
```
[Try it online!](https://tio.run/##SypKzMxLK03O/v9fJ9pOJ9YmOlrXzk7bxgbIsom1i9a10bYDMoFi0XaxIHGgKFDcLhoiA5QD8eyi9exi//83NDI2MTUDAA "brainfuck – Try It Online")
```
,[>,] Read input array into memory
<[[->>+<<] Move last number of input to the right of the input array
<[<]>[-<+>] Move the first number of input to the left the input array
<[->>[>]>+<<[<]<] Move the number left of the input array to the left side of the number(s) to the right of the input array
>>[[-<+>]>]<<] Move the input array to the left to make some space, then repeat
>>>[.>] Print output array
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~88~~ ~~71~~ ~~62~~ ~~60~~ 59 bytes
Saved 9 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!!
Saved a byte thanks to [G. Sliepen](https://codegolf.stackexchange.com/users/46301/g-sliepen)!!!
```
t;i;f(l,n)int*l;{for(;n>1;l[n]=t)t=*l,wmemcpy(l,l+1,n-=2);}
```
[Try it online!](https://tio.run/##fVTbjpswEH3PV4yQUmHiqMGQ3aZetg9VvyJBqxUxWyTiRIBU2ohvT8cXiOPNbqT4MufMeObgcbF8K4rLpeMVL8OaSlLJLqr5uTw2IZfPMa@3Ms860mVRTf8cxKE4/UVevYipXGaM8OFyatAnVH5QU8AZJIHzDPCHUUAhUEEGK47TE0gOi0VFQLuVYTBv5/sA/X7gEHwPcKy3VU74bJgpz8NrJUMyM/GUoRNt97La5hjxHFNgFBIKKYU1hYeB39Li@zQKjz6TGeYGIc1BsvFKNf8bble@TzJFN1Q1@pzUcK7mSNtbYza1UJusnZmdEzunTkzRn0Tfif0ogKmJ6ZTjWwEmqhUh1UWtNftBsx/vsdmHkmkVNp4Qk58Vw8gQvxNj4t0RZMQ0AudrjdQpwlkzZ50469QTv32phTTHtdU/cSxDozf5areR3VNw8djDYw9nHs48PPHwxMNTD0@Jzbv4/dpE0JiMg13/i@36zU/8r1VrOPskQA@vweRe9LbJ9PJpPHOU53rqZNGdqNhjv97cUYxmrqqm5NxlgBxRrbHPME@Cwik@Bp4dex6WzxA49vIj7mcxQjeCuUiY1HSZ7uckboOpUopj04hClRs7GX3yco0OX4wE@FpBhgfj/D5LAvN2J/H7NVvrltvjh9lw@Q8 "C (gcc) – Try It Online")
Inputs a pointer to the array and its length and milks the array in place.
Code actually does the moo-shuffle: tucking the first element away, shifting all but the last down one, and putting the first one just in front of the last. This is repeated, shifting down 2 elements from the end each time, until there are only two elements left and we're done.
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), ~~16~~ 15 bytes
**Solution:**
```
{(#x)_,/|x,'|x}
```
[Try it online!](https://tio.run/##y9bNz/6fZlWtoVyhGa@jX1Oho15TUfs/TV3DUMFIwVjBRMFUwcwaia1gbm2pYA5kGSuARE2AIhYKhgZAJSAuEGv@/w8A "K (oK) – Try It Online")
Port of [Kevin](https://codegolf.stackexchange.com/a/207458/69200)'s solution.
**Explanation:**
```
{(#x)_,/|x,'|x} / the solution
{             } / lambda taking implicit x
            |x  / reverse x
         x,'    / join each with x
        |       / reverse
      ,/        / flatten
     _          / drop
 (  )           / do this together
  #x            / count x
```
**Extra:**
* **-1 byte** thanks to `@ngn`
[Answer]
# JavaScript (ES6), 43 bytes
Using a variant of [Dominic van Essen's approach](https://codegolf.stackexchange.com/a/207460/58563):
```
f=(a,x=a.pop())=>x?[...f(a.reverse()),x]:[]
```
[Try it online!](https://tio.run/##hY/BCoMwDEDv@4ocW8jq1Klz4PYhpYfi6tgQKzrEv@80CtuosB4CTV5ekqcedF92j/a1b@zNOFcVTONYaNHalnFeXMarFEJUTIvODKbrzZTFUZ2lcqVtelsbUds7q5gMESKEGOGIkCCkCr4f5xAEIJdyREQ4Q7s/FoRMeZYjEQmhKYkyT5RPSWJiAiIyTvBp@h7UKtqYRkRO0MZuS8Mcf8/77LaUV9RTeF1bCuXe "JavaScript (Node.js) – Try It Online")
---
# JavaScript (ES6), ~~41~~ 40 bytes
If we can take the length of the array as an extra parameter, the following non-recursive algorithm is shorter:
```
n=>a=>a.map((_,k)=>a[n+++n%2*(~k-k)>>1])
```
[Try it online!](https://tio.run/##bY/LDoIwEEX3fsVsTFop75cs4EdIYxoEo2BLxLj017FMSVSgaZpM5syZ25t4iaF6XPunLdW5Hpt8lHkh9HXuoifkxFqqi1JaliX3wYG8W7ulReFzOlZKDqqrnU5dSEMgoaT0GQQMQgYRg5hBwuH3UAquC6VpB0j4E7RbmNINE4OUr0wREjGiCcrSpcz3tCzTDeRChAK06oGjLj0@yzY2IpEhtMwYm4xmaHr/v/rNaNozutJM6VaTWxo@fgA "JavaScript (Node.js) – Try It Online")
[Answer]
# GNU sed (`-E`), 54 bytes
```
:l;s/(\w+, )(.* )(\w+.*)\]/\2\]\1\3/;tl;s/\]//;s/$/\]/
```
This assumes the array is passed over stdin as text in exactly the same format as in the problem statement (in particular, whitespace is important).
## Explanation/Example
Let's consider the input `[1, 2, 3, 4, 5, 6]` and look at the script statement-by-statement.
1. `:l`: Create a label called `l` to branch to later.
2. `s/(\w+, )(.* )(\w+.*)\]/\2\]\1\3/`: `[1, 2, 3, 4, 5, 6]` -> `[2, 3, 4, 5, ]1, 6`.
3. `tl`: did the last `s` command do something? Yes, so branch to `l`.
4. `s/(\w+, )(.* )(\w+.*)\]/\2\]\1\3/`: `[2, 3, 4, 5, ]1, 6` -> `[3, 4, ]2, 5, 1, 6`.
5. `tl`: did the last `s` command do something? Yes, so branch to `l`.
6. `s/(\w+, )(.* )(\w+.*)\]/\2\]\1\3/`: pattern doesn't match!
7. `tl`: did the last `s` command do something? No, so don't branch.
8. `s/\]//`: `[3, 4, ]2, 5, 1, 6` -> `[3, 4, 2, 5, 1, 6`.
9. `s/$/\]/`: `[3, 4, 2, 5, 1, 6` -> `[3, 4, 2, 5, 1, 6]`.
Note that this works for arrays of text consisting of alphanumeric characters or underscores, not just positive integers.
[Try it online!](https://tio.run/##K05N0U3PK/3/3yrHulhfI6ZcW0dBU0NPC0gA2XpamjGx@jFGMbExhjHG@tYlIEVAEX0gpQJi/P8fbaijYKSjYKyjYKKjYKqjYBbLhSGko2AOFLUEUmA@UAKiwgQsZwHkGkB0QYRBJJAf@y@/oCQzP6/4v64rAA "sed – Try It Online")
[Answer]
# APL+WIN, 40 bytes
Prompts for input of a vector if indices:
```
(,⊖⍉(2,n)⍴(n↑(-n)↓m),⌽(-n←⌈.5×⍴m)↑m←⎕)~0
```
[Try it online! Courtesy of Dyalog Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcjzra0/5r6Dzqmvaot1PDSCdP81HvFo28R20TNXSB7LbJuZo6j3r2AjlA5Y96OvRMD08HqsgFSk3MBQn1TdWsM/gPNOZ/GpehgpGCsYKJgqmCGRcKT8EcyLdUMAeyjRVA4iZAMQsFQwOwMpAAEAPZj3rXcHEBAA "APL (Dyalog Classic) – Try It Online")
# A simpler approach, 26 bytes
```
m[(-⍴m)↑,⌽⍉n,[.1]⌽n←⍳⍴m←⎕]
```
[Try it online! Courtesy of Dyalog Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcjzra0/7nRmvoPurdkqv5qG2izqOevY96O/N0ovUMY4HsPKCyR72bQdIgVt/U2P9APf/TuAwVjBSMFUwUTBXMuFB4CuZAvqWCOZBtrAASNwGKWSgYGoCVgQSAGMh@1LuGiwsA "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 6 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Looking through the rest of the solutions after posting this, I feel like I must be missing something.
```
ÊÆÔvÃÔ
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=ysbUdsPU&input=WzEsIDIsIDMsIDQsIDUsIDZd) or [run all test cases](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=ysbUdsPU&input=WwpbMSwgMiwgMywgNCwgNSwgNl0KWzEsIDIsIDMsIDQsIDUsIDYsIDddCls5LCA3LCA1LCAzLCAxLCAyLCA0LCA2LCA4LCAxMF0KWzEsIDEsIDIsIDEsIDJdCltdCl0tbVI)
JavaScript "translation":
```
U=>[...Array(U.length)].map(_=>U.reverse().shift()).reverse()
```
```
ÊÆÔvÃÔ     :Implicit input of array U
Ê          :Length
 Æ         :Map range
  Ô        :  Reverse U
   v       :  Remove and return first element
    Ã      :End map
     Ô     :Reverse
```
Mapping the original array *would* be one byte shorter but, as both methods used in the map modify that array, it wouldn't work.
[Answer]
# x86-16 machine code, ~~21~~ 20 bytes
**Binary:**
```
00000000: 8bde 03f1 4e03 f94f fda4 e201 c38a 0743  ....N..O.......C
00000010: aae2 f6c3                                ....
```
**Listing:**
```
8B DE       MOV  BX, SI             ; BX = beginning of input array 
03 F1       ADD  SI, CX             ; SI = end of input array  
4E          DEC  SI                 ; adjust to last element 
03 F9       ADD  DI, CX             ; DI = end of output array 
4F          DEC  DI                 ; adjust to last element 
FD          STD                     ; set direction flag to descend 
        MILKLAST:
A4          MOVSB                   ; write end of input array value to output array
E2 01       LOOP MILKFIRST          ; if not end of array, move first value
C3          RET                     ; otherwise, return to caller
        MILKFIRST:
8A 07       MOV  AL, BYTE PTR[BX]   ; AL = start of input array value 
43          INC  BX                 ; increment pointer 
AA          STOSB                   ; write to output array 
E2 F6       LOOP MILKLAST           ; loop until end of array
C3          RET                     ; return to caller
```
Callable function, input array in `[SI]`, length in `CX`. Output array to buffer at `[DI]`.
**Tests using DOS DEBUG:**
[![enter image description here](https://i.stack.imgur.com/Ih2Nd.png)](https://i.stack.imgur.com/Ih2Nd.png)
[![enter image description here](https://i.stack.imgur.com/wOjum.png)](https://i.stack.imgur.com/wOjum.png)
[![enter image description here](https://i.stack.imgur.com/k2RfM.png)](https://i.stack.imgur.com/k2RfM.png)
[Answer]
# [Husk](https://github.com/barbuz/Husk), 8 bytes
```
↓L¹Σze↔¹
```
[Try it online!](https://tio.run/##yygtzv7//1HbZJ9DO88trkp91Dbl0M7///9HG@oY6hiBcCwA "Husk – Try It Online")
```
↓L¹Σze↔¹
    z     Zip 
      ↔¹  the list with its reverse
     e    into a list of 2 elements
   Σ      Flatten it
↓         Drop
 L¹       the first n elements
```
[Answer]
# [Io](http://iolanguage.org/), 53 bytes
Port of @Neil's Charcoal answer.
```
method(x,x map(i,v,x at(if(i%2>0,i,-i-1)>>1))reverse)
```
[Try it online!](https://tio.run/##DcZNCoAgEAbQq7gJZuAL0n4WQZ6kjZDSgFaYRLe33urJWYOaF7XW5Mt@bvTiVcldJHj@uUISSBpjOwhaaTVbq5mzf3y@PddAUe5CGgY9BoyYmNWV5SjxqB8 "Io – Try It Online")
# [Io](http://iolanguage.org/), 68 bytes
Port of @DominicvanEssen's answer.
```
f :=method(x,if(x size>0,list(x pop,f(x reverse))reverse flatten,x))
```
[Try it online!](https://tio.run/##LYrNCoMwEAZfJccsfAfr30Fo30VwgwsxCclSgi@fVvE2M4zE1pxZ3gfrHjdbIc5WU@TkTwcvRf@WYsJVM385FyZ6wDi/qnJAJWrO3vcLPQaMmDATmZQlqA/tBw "Io – Try It Online")
[Answer]
# [Dyalog APL](https://www.dyalog.com/), 28 bytes
```
{⍵≡⍬:⍬⋄0~⍨(∇¯1↓1↓⍵),¯2↑1⌽⌽⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHv1kedCx/1rrEC4kfdLQZ1j3pXaDzqaD@03vBR22QQBirR1Dm03uhR20TDRz17Qah3a@3/R31TPf0ftU0w4EoDkuQbxAU0CGhAmoKhgpGCsYKJgqmCGTYxBXO4qKWCOVDEGCxrApSxUDA0QNICEgZiuAjQQf8B "APL (Dyalog Classic) – Try It Online")
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 102 bytes
```
IEnumerable<int>f(int[]o)=>o.Length==0?new int[0]:o.Length==1?o:f(o[1..^1]).Concat(new[]{o[0],o[^1]});
```
[Try it online!](https://tio.run/##fY89a8MwEIbn6lccpoMEirDb9CuunaF0aMmWoYNQwTVyIkglkNR2MPrt7tkmdEgoiIO759FxbxsWbTDD8PJsvz61bz4O@tHYWHcUq1SOVbUTG213cV9V@drqHxhBrlZ/42LtVh11shDivVBMPDnbNpGiK1Xv0OVOIkisHL4bD1GHGKCCiUNPLo5LsYGCwxWHaw5LDjccbiHx/wUOdyfOAw4nitrsLyfzHtv83MZZGusJTSSVpHNeN@0e6PF@xHMORjAABg7uoMWbN1FvjNX0MpM93UZv7E68OmNpxgHf@IWxpGBRw1mho7OCTsZKkoZf "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [Keg](https://github.com/JonoCode9374/Keg), 34 bytes
```
÷(!½;|")!2%[!1>[$]. ,]{!|$(2|. ,)'
```
[Try it online!](https://tio.run/##y05N////8HYNxUN7rWuUNBWNVKMVDe2iVWL1FHRiqxVrVDSMaoBMTfX//6MNdRSMdIxjAQ "Keg – Try It Online")
+5 due to bug fix
[Answer]
# [Clojure](https://clojure.org/), 40 bytes
```
#(drop(count %)(mapcat vector(rseq %)%))
```
[Try it online!](https://tio.run/##bY/LCsIwEEX3/YoBKUwggn1Zi@CPhCxKmoJSmxpT6d/X6TQ73STcc89MiBncY/Z2xc720K8H7Lyb0Lh5DJAKfLaTaQN8rAnOo3/bF9FUiFUk2LktqgVUojIJuYRCQimhknDWcD3eQO0gZ5Zt@NeUUEe5ZFxxf2a/Jr@hi2nBKOdBqi8UT3Hyz04WGnb4zV3Zzjizp9iQE7FOtAac/H0MwwjYwyLot18 "Clojure – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 36 bytes
```
f@a___:=a
f[a_,b__,c_]:=##&[f@b,a,c]
```
[Try it online!](https://tio.run/##VYuxCoMwFEX3/EbA6RZqtbUVLO8ThI4hPJ6hoQ46SDbJt8eEdulwh3PuvYuEz3uRMDtJyZMwcz@I8kYYEzMc237QujKeJgicTS8nqxm3eQ1Gn56eSNvK0q72Ghc0aHHFLeIP0RXxQJehQSnaLO@oz99hMTkFfs@oYjoA "Wolfram Language (Mathematica) – Try It Online")
Boring, but less boring approaches seem to be more verbose. Returns a `Sequence` containing the deck.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 7 bytes
```
↔;?zcḍt
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//1HbFGv7quSHO3pL/v@PNtQx0jHWMdEx1THTMY/9HwUA "Brachylog – Try It Online")
### Explanation
Same idea as [Kevin's 05AB1E answer](https://codegolf.stackexchange.com/a/207458/16766) (the first one). Suppose the input list is `[1,2,3,4,5]`:
```
↔        Reverse                      [5,4,3,2,1]
 ;?      Pair with the input again    [[5,4,3,2,1],[1,2,3,4,5]]
   z     Zip                          [[5,1],[4,2],[3,3],[2,4],[1,5]]
    c    Concatenate sublists         [5,1,4,2,3,3,2,4,1,5]
     ḍ   Split into two halves        [[5,1,4,2,3],[3,2,4,1,5]]
      t  Take the second half         [3,2,4,1,5]
```
]