Forum Discussion
Anonymous
6 years agoNot applicable
List.Unzip wanted
let suppose we have two lists for which I want to keep the correspondence in the order of the elements. So if I change the order of the first one of the lists, the elements of the second list also a...
- 6 years ago
Hi Anonymous
You can zip it again, this will reverse the zip, or am I missing something?
= List.Zip( List.Zip( { { 1, 2 }, { 3, 4 }, { 5, 6 } } ) )Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
LinkedIn
Smauro
6 years agoSolution Sage
Hey Anonymous ,
I came up with this:
(ListGiven as list) as list =>
let
n = List.Count(ListGiven{0}),
Acc =
(ListGiven, k, n) =>
let
ListK =
if k < n then
List.Transform(ListGiven, each _{k})
else
{},
NewList =
if k < n then
ListK & @Acc(ListGiven, k + 1, n)
else
ListK
in
NewList,
UnZipped = Acc(ListGiven, 0, n)
in
UnZipped
Mariusz' answer is better and certainly easier. What I came up with just gives one list.