><>, 7 15 bytes
l1+2,[v
;!?lo<
Try it here!
This is a full program. To use it simply place the palindrome on the stack, and the result will be outputted to stdout!
Explanation
l get the stack length
1+ add one
2, divide by two
[ pop the value, create a new stack of that length
That's the meat of it, ol?!;
just outputs until the stack is empty.
*><>, 11 bytes (non-competing)
l5+2,]r{[$.
Try it here! (first line is a program that calls the function, outputs the stack, then exits)
This is a function. To use it simply call it (instruction C
) with the palindrome on the stack, and the result will be on the stack! This part is non-competing because *><> is younger than the challenge.
Explanation
l get the stack length
5+ add five
2, divide by two
] close the stack
r reverse the stack
{ shift the stack left
[ pop the value on the end, create a new stack of that length
$ swap the two values on the end of the stack
. jump back, with the result on the stack
For ><> coders who might be confused by this, a new stack is created when a function is called, so you can actually call ]
right from the start if you're inside a function. The data inside this stack is the x, y
coordinate of the ><> when C
was called.