[Question]
  [
Create a program, that converts input string to a palindrome starting with the input string. The program itself must be a palindrome.
For example input: `neverod`, print `neveroddoreven`. You should handle multi-word, multi-line inputs as well.
  
[Answer]
# Dyalog APL, 6 4
```
⌽,,⌽
```
[Try it here.](http://tryapl.org/?a=f%u2190%20%u233D%2C%2C%u233D%20%u22C4%20f%20%27abcde%27&run)
Other solutions:
```
⌽,⊢⊢,⌽
⌽⊢⊢,⊢⊢⌽
```
### Explanation
They are just:
```
{⌽((,⍵),(⌽⍵))}
{⌽((,⍵)⊢((⊢⍵),(⌽⍵)))}
{(⌽⍵)⊢((⊢⍵),((⊢⍵)⊢(⌽⍵)))}
```
Monadic `,` and `⊢` does nothing on strings. Dyadic `,` is concatenation. Dyadic `⊢` returns its right operand. And `⌽` is obviously reversion.
[Answer]
# piet 19x2 = 38
![http://www.pietfiddle.net/img/aoNhlwC47U.png?cs=15&rot=4](https://i.stack.imgur.com/IDIR4.png)
Accepts input until it encounters 0x00. Doesn't terminate, but output will be correct.
[Answer]
## APL, 9
```
⍞←Z,⌽,Z←⍞
```
Explanation:
```
       Z←⍞  ⍝ read a line from the keyboard, and store it in Z
      ,     ⍝ flatten into one-dimensional array (this has no effect here)
     ⌽      ⍝ reverse
   Z,       ⍝ concatenate Z to its reverse
⍞←         ⍝ explicit output (not necessary, but it makes it a palindrome)
```
[Answer]
# CJam, 13 bytes
```
qL;_-1%1-_;Lq
qL;                 "Read the input, Put an empty array on stack and pop that array";
   _-1%             "Now the string is on top, make a copy and reverse the copy";
       1-           "Remove occurrences of integer 1 from the reverse string. [no-op]";
         _;         "Copy the reversed string and pop it";
           Lq       "Put an empty array on stack and read the remaining input. Remaining";
                    "input will be empty as we already read whole of the input";
```
[Try it online here](http://cjam.aditsu.net/#code=qL%3B_-1%251-_%3BLq&input=asdf123)
---
or..
# GolfScript, 9 bytes
```
.-1%}%1-.
.                 "Input is already on stack. Make a copy";
 -1%              "Reverse the copy";
    }             "This marks the beginning of a super comment. Anything after this in the";
                  "code is a comment";
     %1-.         "no-op comment";
```
[Try it here](http://golfscript.apphb.com/?c=OyJhc2RmZzEyMyIKCgouLTElfSUxLS4%3D)
[Answer]
# Haskell, 102+22=124 bytes
```
a b fa=fa<|>b
fa=reverse>>=a
main=interact fa
niam=main
af tcaretni=niam
a=>>esrever=af
b>|<af=af b a
```
This must be run with the `Control.Applicative` module in scope, which can be set via the ghci init file `.ghci`: `:m Control.Applicative` (-> +22 bytes).
No comment trick, just 7 functions where 4 of them are never called.
If functions (instead of programs) are allowed:
# Haskell, 55+22=77 bytes
```
a b fa=fa<|>b
f=reverse>>=a
a=>>esrever=f
b>|<af=af b a
```
Usage `f "qwer"`-> `"qwerrewq"`
Edit: the previous version was just wrong.
[Answer]
## C++, 162 bytes
```
#include<cstdio>//
main(){int c=getchar();if(c>0)putchar(c),main(),putchar(c);}//};)c(rahctup,)(niam,)c(rahctup)0>c(fi;)(rahcteg=c tni{)(niam
//>oidtsc<edulcni#
```
## C, 117 bytes
```
main(c){c=getchar();if(c>0)putchar(c),main(),putchar(c);}//};)c(rahctup,)(niam,)c(rahctup)0>c(fi;)(rahcteg=c{)c(niam
```
[Answer]
# Pyth, 11 bytes
```
+z_z " z_z+
```
In Pyth, anything preceding with a space is not printed. So we simply add the negative of the string to itself, put a space, start a string and mirror the left side of the quote"
[Try it online here](http://pyth.herokuapp.com/?code=%2Bz_z%20%22%20z_z%2B&input=asdfgh)
[Answer]
# Ruby, 44
```
s=gets p
s+=s.reverse||esrever.s=+s
p steg=s
```
Takes a multiline string as input from stdin, outputs a Ruby representation of that string concatenated to its reverse. Could trim a character by replacing `||` with `#` to comment out the dead code on the second line.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 4 bytes
```
êêêê
```
[Try it online!](https://ethproductions.github.io/japt/?v=1.4.6&code=6urq6g==&input=Im5ldmVyb2Qi)
### How it works
```
U.ê("ê".ê("ê"))  Transpiled to JS
       .ê("ê")   String.ê(string): true if `this` is palindrome
    "ê".ê("ê")   true (treated same as 1)
U.ê(          )  String.ê(number): palindromify
                   "abc"->"abccba" if `number` is odd, "abcba" otherwise
                 `true` is odd number, so we achieve the desired function
```
# Alternative 4 bytes
```
pwwp
```
[Try it online!](https://ethproductions.github.io/japt/?v=1.4.6&code=cHd3cA==&input=Im5ldmVyb2Qi)
### How it works
```
U.p("w".w("p"))  Transpiled to JS
    "w".w(   )   Reverse of "w" ("p" is ignored)
U.p("w")         Append U.w(), which is reverse of U, to the right of U
```
[Answer]
## PowerShell, 67
```
$args|%{$_+-join$_[$_.Length..0]}#}]0..htgneL._$[_$nioj-+_${%|sgra$
```
[Try it online](https://tio.run/##BcFRCoAgDADQw7S@xOFBvIHICBpqxAyV@ijPvt676sOtZz5PVdha6t/6Ahl71CJAAQg9SxoZ0cW5zOgQ80jCHgkCgZR6WEPwrl9PbQNVFb651f0H)
As suggested by @mazzy the code can be shortened by 12 bytes when using a static range. This, however, limits the input length to 9KBytes. Theoratically 9MBytes would be possible but it would slow down the code significantly.
```
$args|%{$_+-join$_[9kb..0]}#}]0..bk9[_$nioj-+_${%|sgra$
```
[Answer]
# Jolf, 9 bytes
[Try Here](http://conorobrien-foxx.github.io/Jolf/#code=Yc63K2lfaSvOt2E)
```
aη+i_i+ηa
```
Explanation: I only just started Jolf and I don't think I'm explaining this properly.
```
aη         alert function, arity of the function can't be reduced by 1 so it stays at 1
  +i_i     concatenate the input with the reversed input
      +η   arity of the add reduced by 1, it just takes the following character (a)
        a  returns the input
```
[Answer]
## [<>^v](https://github.com/Astroide/---v), 55 bytes
```
.~""?§0 26 0«0 72!=0_~?(___|___(?~_0=!27 0«0 62 0§?""~.
```
##### Explanation
```
.~""?§0 26 0«0 72!=0_~?(___|___(?~_0=!27 0«0 62 0§?""~.
.                            Input string, push to stack
 ~                           Print top of stack without newline
  ""                         Push empty string to stack
    ?                        Swap top two elements
     §                       Split top of stack (now the user input) with second element of stack (`""`)
      0                      Push 0
        26                   Push 26
           0                 Push 0
            «                Goto ; redirects program to the `|`
                           | Reverses instruction pointer direction, now going left
                          _  Pop stack
                         _   Pop stack (again)
                        _    For the third time, pop the stack
                       )     Decrement top of stack
                      ?      Swap top two elements
                     ~       Print top of stack without newline
                    _        Pop stack
                   0         Push 0
                  =          Execute next instruction only if top two elements of the stack are equal
                 !           Exit, executed only if the top two elements of the stack are equal
               72            Push 27 (pointer is going left, so literal 72 -> value 27
             0               Push 0
            «                Goto _
                          _  (Loop goes on, go back to the first "Pop stack")
                            ___(?~_0=!27 0«0 62 0§?""~. This part is useless and never executed, only for the palindrom requirement
```
What it does is first print the first part of the palindrom, the string itself. Then it stores every letter of the string and the string's length on the stack in reverse order, and print them.
[run online](https://v.astroide.repl.co/#e86c1b42879e59e7696711550bfd6586b97297c9e600e5471d2b5a51644f70fa) (`>` is the prompt, it is not an output of the program)
---
Or, with the string reverse operator :
```
.~—;!;—~.
```
Inputs a string, prints it, reverses it, and prints it.
[run online](https://v.astroide.repl.co/#6c4bd368594074d83cb8b30581d910e40a56301f858a04c84c9f7b1e377a5cb7)
[Answer]
# Fuzzy Octo Guacamole, 17 bytes
```
^dz''sjX@Xjs''zd^
```
Alt solution in 19 bytes:
```
^Czs''.jX@Xj.''szC^
```
They both take input, duplicate and reverse, and join the stack.
Explanation:
```
^dz''sj@js''zd^
^                # Get input
 d               # Duplicate ToS (input)
  z              # Reverse ToS
   ''            # Push empty string (for joining separator)
     s           # Move the empty string to the inactive stack
      j          # Join the active stack with the top of the inactive stack as the delimiter and push the result.
       X         # Print the ToS
        @        # End the program
        Xjs''zd^  # Backwards version of the beginning.
     
```
[Answer]
# [tinyBF](http://esolangs.org/wiki/TinyBF), 40
```
|=||==>|=|=|=+|=>==||==>=|+=|=|=|>==||=|
```
My first thought was Brainfuck, but it's impossible to match the braces... fortunately tinyBF has simpler flow control. 
No comments, it takes a null terminated string as input and returns the result in a null terminated string. You can test it [here](http://bataais.com/tinyBF.html), just be forewarned that it doesn't halt (although Firefox at least prompts to stop the unresponsive script). 
**Commented:**
```
|=|                        Retrieve a byte of input.
|                          Positive (opening) bracket.
   ==                      Output the byte.
   >                       Move the pointer in positive direction.
   |=|                     Retrieve a byte of input.
   =                       Switch direction to negative.
|                          Negative (closing) bracket.
=                          Switch direction.
+                          Increment byte to execute return loop.
|                          Opening bracket.
   =>                      Move the pointer in negative direction.
   ==                      Output the byte.
|                          Closing bracket.
|=|                        Output the null terminator.
|==>|=|=|=+|=>==|          ...and keep null terminating it just to be sure.
```
Note that if you encode it into 2 bit instructions, it cuts the size to 10 bytes (wouldn't be a palindrome).
[Answer]
## Python 3, 59 bytes
```
a=input()#
print(a+a[::-1])#([1-::]a+a)tnirp
#()tupni=a
```
I tried my best to find a solution that only used one line but I had no luck.
## Python 3, 79 bytes
```
a=input()#()tupni=a#
print(a+a[::-1])#([1-::]a+a)tnirp
#a=input()#()tupni=a
```
My original attempt in which every line is a palindrome. I don't think that it is necessary for this challenge, but I included it just in case.
[Answer]
# Vitsy, 9 bytes
```
z:Zr?rZ:z
z          Grab all string input from the command line arguments.
 :         Duplicate this stack.
  Z        Print all elements in this stack as a string.
   r       Reverse (reverses an empty stack).
    ?      Go right a stack.
     r     Reverse (reverses the input).
      Z    Print all elements in this stack as a string.
       :   Duplicate the stack (duplicates an empty stack).
        z  Grab all input from the command line (the command line arguments stack is already empty).
```
[Try it online!](http://vitsy.tryitonline.net/#code=ejpacj9yWjp6&input=&args=VGhpcyBpcyBhIHN0cmluZy4)
[Answer]
# [Befunge](http://github.com/catseye/Befunge-93), 37 bytes
```
~:0`!#v_:,
  >:#,_@_,#:>  
,:_v#!`0:~
```
[Try it online!](http://befunge.tryitonline.net/#code=fjowYCEjdl86LAogID46IyxfQF8sIzo-ICAKLDpfdiMhYDA6fg&input=bmV2ZXJvZA)
The top line pushes and prints every character of input. The second line (before the `@`) prints the stack in reverse, but we enter at the contional `_` to consume the -1 generated when finish reading input. The other half of the code (including those ugly trailing newlines) makes the source a palindrome, but nevers runs.
[Answer]
# C# (~~33~~ 32 + 1) \* 2 = ~~68~~ 66 bytes
saved 2 bytes to the use of .Aggregate()
```
s=>s+s.Aggregate("",(a,b)=>b+a);//;)a+b>=)b,a(,""(etagerggA.s+s>=s
```
Oh the good old lambda, you can catch it with
```
Func<string, string> f=<lambda here>
```
and then call it with
```
f("neverod")
```
[Answer]
## Perl, 45 bytes
```
;print$_=<>,~~reverse;m;esrever~~,><=_$tnirp;
```
Pretty straightforward, `print`s the input (`$_=<>`) followed by the `reverse` of it. `reverse` returns `$_` because we're using it in scalar context by prefixing with `~~`. Then we match (`m//` using `;` as delimiter), in void context, against the reverse of the script.
If we can guarrantee we won't have to create a palindrome of `esrever,><=_$tnirp` we can shorten the code to **43 bytes**:
```
g.print$_=<>,reverse.m.esrever,><=_$tnirp.g
```
### Usage
```
echo -n 'neverod' | perl -e 'g.print$_=<>,reverse.m.esrever,><=_$tnirp.g'
neveroddoreven
```
---
## Perl, 26 bytes
**Includes 25 bytes code + 1 for `-p`.**
```
$_.=reverse;m;esrever=._$
```
I don't think this is valid since it requires the `-p` flag which I don't think can be easily combined into the script contents to make a true palindrome. Pretty much the same calls as above, except it relies on the fact that `-p` also adds a `;` behind the scenes (on newer Perls...) to close the `m//`.
### Usage
```
echo -n 'neverod' | perl -pe ';$_.=reverse;m;esrever=._$;'
neveroddoreven
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 1 byte
```
m
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJtIiwiIiwiYmFnIl0=)
A simple 1-byter - `m` mirrors input by appending its reverse.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~5~~ 3 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
R«R
```
-2 bytes thanks to *@ovs*.
[Try it online.](https://tio.run/##yy9OTMpM/f8/6NDqoP//lZSUSjIyi7mAKJGrJLW4BCgAAA)
**Explanation:**
```
R        # Reverse the (implicit) input
         #  i.e. "neverod" → "doreven"
 «       # Append it to the (implicit) input
         #  → "neveroddoreven"
  R      # Reverse it (no-op, since it's a palindrome)
         # (after which the result is output implicitly)
```
If we are allowed to output `neverodoreven` for the input `neverod`, which is still a palindrome, it can be done in **1 byte** instead with the palindromize builtin:
```
û
```
[Try it online.](https://tio.run/##yy9OTMpM/f//8O7//5WUlEoyMou5gCiRqyS1uAQoAAA)
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), ~~5~~ 3 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
x+x
```
[Try it online.](https://tio.run/##y00syUjPz0n7/79Cu@L/f6W81LLUovwUJS6lpJxEIGloZGxiamZuYakEAA)
Or 1 byte if overlapping the last character would be allowed, with the palindromize builtin:
```
ñ
```
[Try it online.](https://tio.run/##y00syUjPz0n7///wxv//lfJSy1KL8lOUuJSSchKBpKGRsYmpmbmFpRIA)
**Explanation:**
```
x    # Reverse the (implicit) input
 +   # Append it to the (implicit) input
  x  # Reverse it (no-op, since it's a palindrome)
     # (after which the entire stack is output implicitly)
```
[Answer]
# Pyth, 15
```
 k k+ z_z +k k 
```
Notice the space at the beginning and at the end. 
Quite annoying task in Pyth. `z_z` prints the desired palindrome, but it prints `z` (the input string) and `_z` the inverse on two different lines. `+` combines the two words, but `+` at the end requires two new statements at the end (and at the beginning). I choose `k` and `k`, which are just empty strings. Then a lot of white space, which suppresses printing (and printing empty spaces, which generate of course line breaks). 
Since the white space suppresses every output except the `+z_z`, you can replace the `k`s and literal with arity 0. E.g. `1 2+ z_z +2 1` or `T Z+ z_z +Z T`. 
Try it [online](https://pyth.herokuapp.com/?code=%20k%20k%2B%20z_z%20%2Bk%20k%20&input=neverod&debug=0).
[Answer]
# JavaScript, 58 bytes
```
p=>p+[...p].reverse().join``//``nioj.)(esrever.]p...[+p>=p
```
[Answer]
# PHP, 28+1+28=57 bytes
```
<?=($x=$argv[1]).strrev($x);#;)x$(verrts.)]1[vgra$=x$(=?<
```
takes input from command line argument. quote for multi-word, escape newlines for multi-line.
[Answer]
# Python 2, 51 bytes
```
s=input();print s+s[::-1]#]1-::[s+s tnirp;)(tupni=s
```
I'm surprised no-one thought of this! Needs quoted input (`'` or `"`). If functions were allowed, I could have done this for 37 bytes instead:
```
lambda x:x+x[::-1]#]1-::[x+x:x adbmal
```
[Answer]
# C++14, ~~152~~ 116 bytes
As unnamed lambda, assumes `s` to be `string`
```
[](auto s){decltype(s)r;for(auto c:s){r=c+r;}return s+r;}//};r+s nruter};r+c=r{)s:c otua(rof;r)s(epytlced{)s otua(][
```
Old solution:
```
[](auto s){auto r=s;for(auto p=s.rbegin()-1;++p!=s.rend();r+=*p);return r;}//};r nruter;)p*=+r;)(dner.s=!p++;1-)(nigebr.s=p otua(rof;s=r otua{)s otua(][
```
Usage:
```
auto f=[](auto s){decltype(s)r;for(auto c:s){r=c+r;}return s+r;};
main(){
 string a="123456789";
 cout << f(a) << endl;
}
```
[Answer]
# x86-64 Assembly (Microsoft x64 calling convention), 89 bytes:
```
80 39 00 48 8B D1 4C 8B C1 74 0B 48 FF C2 49 FF C0 80 3A 00 75 F5 48 FF CA 8A 02 41 88 00 48 8B C2 48 FF CA 49 FF C0 48 3B C1 77 ED C3 ED 77 C1 3B 48 C0 FF 49 CA FF 48 C2 8B 48 00 88 41 02 8A CA FF 48 F5 75 00 3A 80 C0 FF 49 C2 FF 48 0B 74 C1 8B 4C D1 8B 48 00 39 80
```
Disassembled:
```
 0000000000000000: 80 39 00           cmp         byte ptr [rcx],0
 0000000000000003: 48 8B D1           mov         rdx,rcx
 0000000000000006: 4C 8B C1           mov         r8,rcx
 0000000000000009: 74 0B              je          0000000000000016
 000000000000000B: 48 FF C2           inc         rdx
 000000000000000E: 49 FF C0           inc         r8
 0000000000000011: 80 3A 00           cmp         byte ptr [rdx],0
 0000000000000014: 75 F5              jne         000000000000000B
 0000000000000016: 48 FF CA           dec         rdx
 0000000000000019: 8A 02              mov         al,byte ptr [rdx]
 000000000000001B: 41 88 00           mov         byte ptr [r8],al
 000000000000001E: 48 8B C2           mov         rax,rdx
 0000000000000021: 48 FF CA           dec         rdx
 0000000000000024: 49 FF C0           inc         r8
 0000000000000027: 48 3B C1           cmp         rax,rcx
 000000000000002A: 77 ED              ja          0000000000000019
 000000000000002C: C3                 ret
 000000000000002D: ED                 in          eax,dx
 000000000000002E: 77 C1              ja          FFFFFFFFFFFFFFF1
 0000000000000030: 3B 48 C0           cmp         ecx,dword ptr [rax-40h]
 0000000000000033: FF 49 CA           dec         dword ptr [rcx-36h]
 0000000000000036: FF 48 C2           dec         dword ptr [rax-3Eh]
 0000000000000039: 8B 48 00           mov         ecx,dword ptr [rax]
 000000000000003C: 88 41 02           mov         byte ptr [rcx+2],al
 000000000000003F: 8A CA              mov         cl,dl
 0000000000000041: FF 48 F5           dec         dword ptr [rax-0Bh]
 0000000000000044: 75 00              jne         0000000000000046
 0000000000000046: 3A 80 C0 FF 49 C2  cmp         al,byte ptr [rax+FFFFFFFFC249FFC0h]
 000000000000004C: FF 48 0B           dec         dword ptr [rax+0Bh]
 000000000000004F: 74 C1              je          0000000000000012
 0000000000000051: 8B 4C D1 8B        mov         ecx,dword ptr [rcx+rdx*8-75h]
 0000000000000055: 48 00 39           add         byte ptr [rcx],dil
 0000000000000058: 80
```
Note that the code after the `ret` instruction at `2C` is unreachable so it doesn't matter that it's nonsense
[Answer]
# [Backhand](https://github.com/GuyJoKing/Backhand), ~~33~~ 27 bytes
```
iH~0}|{<:: oi]io ::<{|}0~Hi
```
[Try it online!](https://tio.run/##S0pMzs5IzEv5/z/To86gtqbaxspKIT8zNjNfwcrKprqm1qDOI/P//8SkZAA "Backhand – Try It Online")
Unlike a lot of the solutions here, this one actually *does* use the palindromised code!
### Explanation:
```
i  0 |{      Get the first character and enter the loop
        :  o    Output the character while preserving it
              i  :     Get input and duplicate it
                   <{  Turn around
             ]         Increment the copy to check if EOF   
    }| <    Loop again if not EOF
  ~   If EOF, pop the extra copy of EOF
 H    Terminate, printing the contents of the stack.
```
Altogether, the unexecuted instructions are:
```
       :   i  o :   |}0~Hi
```
[Answer]
# [Python 3](https://docs.python.org/3/), 53 bytes
```
t=input();print(t+t[::-1])#)]1-::[t+t(tnirp;)(tupni=t
```
[Try it online!](https://tio.run/##DcgxDoAgDAXQw7i0MQzErYSTEHa7fBvyGTx99Y0vXt4Prkx2R2yKtlgOCk8Os1KnHjprMRv/COErmgp3wDszPw "Python 3 – Try It Online")
]