# Why does my threaded function need to be substituted?

In my code I have

With[
{
rowCells=(genCells[#]&/@genSpecs[#])&/@clueRows,
colCells=(genCells[#]&/@genSpecs[#])&/@clueCols
},
While[Not@isDone@Flatten@constraintTable,
/.f-> constraintStrip)\[Transpose];
]
]


but when I attempt to replace the substitutions for f with

With[
{
rowCells=(genCells[#]&/@genSpecs[#])&/@clueRows,
colCells=(genCells[#]&/@genSpecs[#])&/@clueCols
},
While[Not@isDone@Flatten@constraintTable,
/.f-> constraintStrip)\[Transpose];
]
]


I get

Transpose::nmtx: The first two levels of {Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0],Transpose[0]} cannot be transposed. >>
Transpose::nmtx: "The first two levels of {Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[],Transpose[]} cannot be transposed. \!\(\*ButtonBox[\">>\",


Why do I need to substitute in this way? How can avoid having to do so?

I have a similar issue with

showTable[t_]:=
Grid[
Join[
Join[
(t/.cellGraphics)
]
]/.f->Join)
],
gridSpecs
];


where a substitution is also required in Thread to avoid errors.

• Thread evaluates its argument before threading, so perhaps the problem comes from evaluating constraintStrip[rowCells,constraintTable]. – Simon Woods Dec 14 '15 at 21:20
• @SimonWoods: How can it thread over something if it evaluates the whole thing first? – orome Dec 14 '15 at 21:23
• For many things that's no problem: Thread[{a,b}->{1,2} yields {a->1,b->2}, which is quite useful. – Sjoerd C. de Vries Dec 14 '15 at 21:26
• If that is the source of the problem, the question is essentially a duplicate of this one – Simon Woods Dec 14 '15 at 21:27
• It's not messed up, {1,2,3}=={1,2,3} evaluates to True - what do you think the result of Thread[True] should be? – Simon Woods Dec 14 '15 at 22:06

MapThread[Join, {colCells, constraintTable\[Transpose]}]

• Yes, MapThread gives the expected behavior, but why have Thread behave this way at all? – orome Dec 14 '15 at 23:07
• But why have Thread do that? Why have Thread designed to not thread in some cases. – orome Dec 14 '15 at 23:16
• I don't think Join comes into play in the first case though, where f is constraintStrip. – orome Dec 14 '15 at 23:28