Quantcast
Channel: Adding elements to some sublists of unequal length - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 7

Answer by E. Chan-López for Adding elements to some sublists of unequal length

$
0
0

Another method using GroupBy:

Values[GroupBy[Catenate[{a, b}], First, If[Length[#] == 2, Sequence @@@ {#[[1, All]], #[[2]][[2;;]]}, #[[1]]] &]](*{{1, 3, 5, 2}, {2, 6, 2, 1}, {3, 5, 6, 1, 2}, {4, 2, 3}}*)

Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>