none
List.Zip - Incomprehensive Implementation Logic RRS feed

  • Question

  • In the September 2016 version of Power BI, the List.Zip function was introduced. However, I'm totally baffled by the design decisions made in the implementation logic:

    Until this function was introduced, the development team made a very conscious decision to rename every list function used by virtually every other functional language (except for sort). Very common functions like map, filter, and fold were renamed in M as transform, select, and accumulate.  I thought this was done in an effort to make the names more intuitive to understand compared to the industry standard names. However, List.Zip suggests that my thinking was faulty, as there isn't a person on the planet, who haven't encountered this name before in another functional language, that would guess what this function does (other than to think that it might have something to do with compression! - which is not the case).

    Adding insult to injury, List.Zip doesn't even work the way the Zip function works in every other functional language, making the choice of such an unintuitive name even more baffling.

    About a year ago, I created a custom function that works exactly how List.Zip works:

    (listOfLists as list) as list=>
    let
        Table = Table.FromColumns(listOfLists),
        TransposedList = Table.ToRows(Table)
    in
        TransposedList

    However, I named the function List_Transpose, which makes far more sense than List.Zip, given what the function actually does.

    What facts am I missing in the preceding argument?    

     Thx
    Wednesday, October 26, 2016 9:58 PM

Answers

  • When you say that List.Zip works differently than in other languages, is that because of its behavior when the lists are of unequal length?

    I agree that List.Transpose might have been a better name.

    Friday, October 28, 2016 1:45 PM

All replies

  • When you say that List.Zip works differently than in other languages, is that because of its behavior when the lists are of unequal length?

    I agree that List.Transpose might have been a better name.

    Friday, October 28, 2016 1:45 PM
  • When you say that List.Zip works differently than in other languages, is that because of its behavior when the lists are of unequal length?

    I agree that List.Transpose might have been a better name.

    Hi Curt,

    Yes, exactly! Also, it was long after I wrote my custom function that I discovered that Haskell introduced a list transpose function. It is more similar to how List.Zip works than how the industry standard zip function works with unequal length lists! So essentially List.Transform(List.Zip({BunchOfLists}), List.RemoveNulls) = Haskell list transpose.

    Don't get me wrong, I appreciate the new function. I know what it does, and it eliminates one more custom function from my library (that's about a dozen in the last three years! :)). My concern is for ordinary users and pros alike, who would be unfamiliar with zip in the first place. I've asked many people (including , gasp, my wife) what they thought List.Zip does, and every response was that it had something to do with compressing a list - not good.

    Friday, October 28, 2016 9:08 PM