我有listA和listB相同的大小.我做GatherBy的listA,这是重排列表.应用相同重排的优雅方法是什么listB?
例如
listA = {1, 2, 3};
listB = {a, b, c};
listA1 = GatherBy[{1, 2, 3}, OddQ];
Run Code Online (Sandbox Code Playgroud)
listB1 应该成为 {{a, c}, {b}}
更新 感谢有趣的想法,我最终做了类似于belisarius的事情.这让我想起了Python的"decorate-sort-undecorate"模式
decorated = Thread[{listA, listB}];
grouped = GatherBy[decorated, OddQ[First[#]] &];
listB1 = Map[Last, grouped, {2}]
Run Code Online (Sandbox Code Playgroud) 什么是f [x _]的倒数:= Flatten [x]其中x是具有维度变暗的数组?