In my code I have
With[
{
rowCells=(genCells[#]&/@genSpecs[#])&/@clueRows,
colCells=(genCells[#]&/@genSpecs[#])&/@clueCols
},
While[Not@isDone@Flatten@constraintTable,
constraintTable=(Thread[f[rowCells,constraintTable]]/.f-> constraintStrip);
constraintTable=(Thread[f[colCells,constraintTable\[Transpose]]]
/.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,
constraintTable=(Thread[constraintStrip[rowCells,constraintTable]]);
constraintTable=(Thread[constraintStrip[colCells,constraintTable\[Transpose]]]
/.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[
ConstantArray["",{9,9},(Style[#,Bold]&/@PadLeft[#,9,""]&/@clueCols)]\[Transpose],
(Thread[f[(Style[#,Bold]&/@PadLeft[#,9,""]&/@clueRows),
(t/.cellGraphics)
]
]/.f->Join)
],
gridSpecs
];
where a substitution is also required in Thread to avoid errors.
Threadevaluates its argument before threading, so perhaps the problem comes from evaluatingconstraintStrip[rowCells,constraintTable]. – Simon Woods Dec 14 '15 at 21:20Thread[{a,b}->{1,2}yields{a->1,b->2}, which is quite useful. – Sjoerd C. de Vries Dec 14 '15 at 21:26Inactivatef. – Sjoerd C. de Vries Dec 14 '15 at 21:27(MapThread[constraintStrip, {rowCells,constraintTable}]), which the documentation says is the same thing, works fine. – orome Dec 14 '15 at 21:27constraintStripover the arguments given; the given arguments themselves don't make sense forconstraintStrip, so evaluating it wouldn't work. – orome Dec 14 '15 at 21:29fis undefined, doesn't evaluate and can then be threaded. – Sjoerd C. de Vries Dec 14 '15 at 21:38Threaddocs work?Thread[f[{a, b, c}, {x, y, z}]]can't work iffdoes't take lists arguments, thoughf[a,x], etc. certainly can. What am I missing. And if the objective is to produce a list of such values (as in the docs,{f[a,x], f[b,y], f[c,z]}, isn't that whatThreadis for? – orome Dec 14 '15 at 21:42Thread[{1,2,3}=={1,2,3}]isTrue, butThread[{1,2,3}=={1,c,3}]is{True, False, True}unless is defined, say asc=2, in which case it'sTrue. So the whole structure of the result — in fact, whether any threading even takes place — depends on whether all the components of the arguments can be fully evaluated. Talk about side effects! – orome Dec 14 '15 at 21:57{1,2,3}=={1,2,3}evaluates toTrue- what do you think the result ofThread[True]should be? – Simon Woods Dec 14 '15 at 22:06Threadactually threads is contingent on whether every component of the arguments it's meant to thread over can be fully evaluated; if they can, threading will not happen. – orome Dec 14 '15 at 22:12MapThreadis clearly what I should be using,Threadis clearly some other nutty thing that makes no sense. – orome Dec 14 '15 at 22:13Threadprovide such uses by not threading (essentially as a side effect). – orome Dec 14 '15 at 22:39