Let's look at it from the inside out, starting with
{#,#,#,#} &
This is a nameless function which takes any input and returns a list containing that input 4 times by directly repeating its argument.
{#,#,#,#} & /@ A
This Map
s (/@
is a shorthand infix for Map
) the nameless function over every member of A
. This returns a list containing lists of 4 copies for every member of A
.
Flatten[{#,#,#,#} & /@ A]
This flattens that list of lists back into a normal list, effectively creating a 1D list repeating each element of A
4 times in the same order that A
has them.
Flatten[{#,#,#,#} & /@ A][[2 ;; -2]]
This then takes the second through second to last members of that list, discarding the very first and the very last elements.
Partition[Flatten[{#,#,#,#} & /@ A][[2 ;; -2]], 2]
Finally this breaks the list into non-overlapping pairs, starting from the beginning.
{#, #, #, #} & /@ A
thenFlatten[%]
etc? $\endgroup$ – Kuba♦ Feb 14 '18 at 19:55