Skip to main content
Bumped by Community user
edited tags
Link
Source Link
lineage
  • 1.2k
  • 5
  • 11

level 2 MapThread over association

Consider a 2D array of Associations. MapThread is used to simultaneously supply it to some function with other args

assocs = Map[Association @@ Distribute[{"a", "b", "c"} -> RandomInteger[100], List] &,  comps,{2}];
Grid@assocs

MapThread[#1["a"] &, {assocs(*,otherArgs*)}, 2]

gives

MapThread::mptd: Object {{<|a->67,b->67,c->67|>},{<|a->57,b->57,c->57|>},{<|a->100,b->100,c->100|>},{<|a->58,b->58,c->58|>,<|a->50,b->50,c->50|>,<|a->72,b->72,c->72|>}} at position {2, 1} in MapThread[#1[a]&,{{{<|a->67,b->67,c->67|>},{<|a->57,b->57,c->57|>},{<|a->100,b->100,c->100|>},{<|a->58,b->58,c->58|>,<|a->50,b->50,c->50|>,<|a->72,b->72,c->72|>}}},2] has only 1 of required 2 dimensions.

Answer at MapThread with non-rectangular lists suggest that the non-rectangular strucure of the list is to be blamed. However, I am finding it difficult to implement the accepted and upvoted answer there

Function[Null, f[##], Listable] @@ A

given without any examples.

So how does one use MapThread at level 2 independent of rectangularity?