Elixir's `Enum.transpose/1` written by ChatGPT?

So I was going back and forward with ChatGPT about Elixir and tried making something using only GPT (it seems to be hot topic rn). Anyhow, suddenly ChatGPT gave me advice to use Enum.transpose. And when I told him that doesn’t exist, he continued to hallucinate. So I went down the rabbit hole and got this :smiley:
Any thoughts about implementing/adding this new function into the Enum module? :nerd_face:

1 Like

This is a good reminder that, as impressive as they are, models like GPT are great at producing plausible content, not correct one :slight_smile:

Slight detour: I even think that it would be great if GPT-like models could express uncertainty in their output. Right now they sound like an overconfident but ultimately mistaken person that knows some stuff but is far from really understanding the topic.

Anyway, my opinion is that transpose is a special purpose function that only makes sense if the enumerable is representing a matrix as a collection of rows. As such, I don’t think that such a special case has its right place in Enum. In fact, depending on what the enumerable is, there are more efficient ways to do that.

5 Likes
[
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
]
|> Enum.zip_with(& &1)
# [
#   [1, 4, 7], 
#   [2, 5, 8], 
#   [3, 6, 9]
# ]
6 Likes

Yep, great point, Enum.zip_with used like shown has the same effect, and is a much more general utility function.

Exactly, what is even worse, I know a company that started using it to write documentation for code.
I think that with more domain training and better fact-checking it can be a really helpful tool

Yeah this sounds like a recipe for trouble :slight_smile:

2 Likes

I asked a question for fun about a gapfilling function I wrote and asked it to improve my code.

Part of it’s response was to use Enum.fill (which also doesn’t exist) :sweat_smile:

Firmly impaled atop Mount Stupid:
image
(from Mount Stupid | ASC Psychological Services)