| Bytes | Lang | Time | Link |
|---|---|---|---|
| 007 | Japt h | 241022T091854Z | Shaggy |
| 012 | Uiua | 241022T000655Z | nyxbird |
| 025 | Pip | 170311T043157Z | DLosc |
| 063 | Python 2 | 170310T174146Z | Rod |
| 064 | Python 2 | 170310T181341Z | Jonathan |
| 087 | JavaScript ES6 | 170310T181922Z | Neil |
| 051 | Haskell | 170310T180818Z | nimi |
| 006 | Jelly | 170310T172208Z | Jonathan |
| 015 | APL | 170310T174357Z | marinus |
| 004 | 05AB1E | 170310T172257Z | mbomb007 |
| 066 | Groovy | 170310T173156Z | Magic Oc |
Japt -h, 7 bytes
ÆV=mê ê
ÆV=mê ê :Implicit input of integer U & array V
Æ :Map the range [0,U)
V= : Reassign to V
m : Map
ê : Palindromise
ê : Palindromise
:Implicit output of last element
Uiua, 12 bytes
⍥(⊂:↘1⊸⇌⍉)×2
⍥(⊂:↘1⊸⇌⍉)×2
⍥( )×2 # repeat 2*n times:
⍉ # transpose
⊸⇌ # reverse (keep original)
↘1 # drop the first element
⊂: # append to original
Repeating by twice n and ⍉ transposing lets the palindromization work on both rows and columns.
Pip, 25 bytes
24 bytes of code, +1 for -l flag.
Lq{gM:_.@>RV_gAL:@>RVg}g
Takes the list as command-line arguments and the number n from stdin. Try it online!
Explanation
g is list of cmdline args (implicit)
Lq{ } Read a line of input and loop that many times:
_.@>RV_ Lambda function: take all but the first character (@>) of the
reverse (RV) of the argument (_), and concatenate that (.) to
the argument (_)
gM: Map this function to g and assign the result back to g
@>RVg Take all but the first element of the reverse of g
gAL: Append that list to g and assign the result back to g
g After the loop, print g (each item on its own line due to -l)
Python 2, 71 63 bytes
lambda x,n,f=lambda x:x+x[-2::-1]:eval('f(map(f,'*n+`x`+'))'*n)
Assign a palindrome function to f, generate and evaluate the following pattern (for n=4)
f(map(f,f(map(f,f(map(f,f(map(f,<input>))))))))
Python 2, 64 bytes
h=lambda a:a+a[-2::-1]
f=lambda a,n:n and f(h(map(h,a)),n-1)or a
Try it online! - footer prints each of the elements of the resulting list, one per line, a "pretty print".
h is the palindomisation function, it appends to the input, all the elements of a list from the last but one, index -2, to the start in steps of size -1.
f calls h with the result of calling h on each element in turn, reduces n by one and calls itself until n reaches 0, at which point a is the finished product.
JavaScript (ES6), 87 bytes
f=(n,l,r=l=>[...a].reverse().slice(1))=>n--?f(l.concat(r(l)).map(s=>s+r(s).join``),n):l
Haskell, 51 bytes
x%n=iterate((++)<*>reverse.init)x!!n
x?n=(%n)<$>x%n
Usage example: ["123","456","789"] ? 1 ->
["12321","45654","78987","45654","12321"]. Try it online!.
(++)<*>reverse.init makes a palindrome out of a list, iterate(...)x repeats this again and again and collects the intermediate results in a list, !!n picks the nth element of this list. (%n)<$>x%n makes a n-palindrom of each element of the n-palindrome of x.
Jelly, 6 bytes
ŒḄŒB$¡
Dyadic link, or full program taking the list and n.
Using both versions of Lynn's fantastic built-in "bounce".
ŒḄŒB$¡ - Main link: l, n
¡ - repeat n times
$ - last two links as a monad (firstly with l then the result...)
ŒḄ - bounce ("palindromise") the list
ŒB - bounce the elements
APL, 15 bytes
(Z¨Z←⊢,1↓⌽)⍣⎕⊢⎕
Explanation:
(...)⍣⎕⊢⎕: read the list andNas input, and runNtimes:⊢,1↓⌽: the list, followed by the tail of the reversed listZ←: store this function inZZ¨: and apply it to each element of the list as well
Test:
(Z¨Z←⊢,1↓⌽)⍣⎕⊢⎕
⎕:
'hat' 'mad' ' a '
⎕:
2
┌─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐
│hatahatah│madamadam│ a a a a │madamadam│hatahatah│madamadam│ a a a a │madamadam│hatahatah│
└─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘
05AB1E, 4 bytes
Note that if only a single iteration was required (n=1), then the program would be the palindrome û€û.
Fû€û
F Do n times
û Palindromize the list
€û Palindromize each element in the list
If padding the input was still a required part of the program (11 bytes):
€R.B€RIFû€û
I couldn't find a shorter way to right-justify. Left-justification and centering were all easy, but this was longer for some reason. Using E or ² instead of I also works.
Groovy, 66 bytes
{x,n->f={z->z+z[z.size()-2..0]};n.times{x=f(x).collect{f(it)}};x}