Skip to main content
remove superfluous Function; add links and output
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

Using ReapReap and SowSow:

Transpose[
 Last@Reap[
   MapThread[Sow[#1, #2] &MapThread[Sow, weightsPerclass], _, {#1, Total@#2} &]]
{{1, 2, 3, 5}, {2.6, 0.2, 0.4, 0}}

Using Reap and Sow:

Transpose[
 Last@Reap[
   MapThread[Sow[#1, #2] &, weightsPerclass], _, {#1, Total@#2} &]]

Using Reap and Sow:

Transpose[
 Last@Reap[
   MapThread[Sow, weightsPerclass], _, {#1, Total@#2} &]]
{{1, 2, 3, 5}, {2.6, 0.2, 0.4, 0}}
Source Link
ubpdqn
  • 64.8k
  • 3
  • 65
  • 154

Using Reap and Sow:

Transpose[
 Last@Reap[
   MapThread[Sow[#1, #2] &, weightsPerclass], _, {#1, Total@#2} &]]