The code has three places with same variable ls. So I think it would be possible to write it as a pure function.
ls = {{1, a}, {2, b}, {3, c}};
MapThread[Insert, {ls, Table[0, {Length[ls]}], Table[2, {Length[ls]}]}]
My attempt is:
MapThread[Insert, {#, Table[0, {Length[#]}], Table[2, {Length[#]}]} & ls]
which is not correct.
& @lsinstead of& lswould also work. Writing& lsis like writingf ls, which in Mathematica syntax meansf multiplied by ls- and you can't multiply an anonymous function with a list. – C. E. Jan 07 '16 at 07:34Length@(#&ls), does this contradict with what you are saying? – an offer can't refuse Jan 07 '16 at 07:39Riffle[#, 0] & /@ ls? – ciao Jan 07 '16 at 07:39# & lsreturns and whyLengthis "correct". I'voting to close this question as a duplicate of common pitfals. But you may also by interested inFunctionPure Functionentries in documentation. – Kuba Jan 07 '16 at 07:43Column @@ FullForm[# & ls]to see what I mean, those expressions that you generate by multiplyinglswith# &don't mean anything. – C. E. Jan 07 '16 at 07:43