Rich_Morin
Is anyone using AI assistance in coding Elixir?
I’m curious whether anyone is using AI (really, LLM) assistance in coding Elixir (especially in Livebooks). If so, which chatbots (etc) seem to be working the best?
First Post!
CharlesIrvine
I use ChatGPT quite a bit by asking - “How do I do this using Elixir?” The answers are usually pretty good. Here’s a question I just asked today along with the response:
My question:
Using Elixir, how do I check to see if two lists have the same members, regardless of the order?
ChatGPT said:
ChatGPT
In Elixir, you can check if two lists contain the same members, regardless of order, by sorting each list and comparing them. This approach works because sorting ensures both lists will have the same order if they contain the same elements.
Here’s a simple example:
def same_members?(list1, list2) do
Enum.sort(list1) == Enum.sort(list2)
end
Example Usage
same_members?([1, 2, 3], [3, 2, 1]) # returns true
same_members?([1, 2, 3], [3, 2, 2]) # returns false
This approach works well for lists with unique elements. However, if you have large lists and performance is a concern, you might consider using a different approach that doesn’t require sorting, such as converting the lists to maps of element counts and comparing those.
You said:
Are you sure there isn’t a built in function that does this check?
ChatGPT said:
ChatGPT
You’re right; Elixir actually has a built-in function for this exact purpose: Enum.frequencies/1. By using it, you can create a frequency map for each list and then compare those maps directly, which is both efficient and concise.
Here’s how you can do it:
def same_members?(list1, list2) do
Enum.frequencies(list1) == Enum.frequencies(list2)
end
Example Usage
same_members?([1, 2, 3], [3, 2, 1]) # returns true
same_members?([1, 2, 3], [3, 2, 2]) # returns false
Using Enum.frequencies/1 is beneficial because it directly compares the counts of each unique element in each list, which avoids sorting and is faster for large lists.
Most Liked
ipnon
It will direct you to your particular Dunning-Kruger minima as fast as possible and once there assure you that a better solution is inconceivable.
dimitarvp
I was about to write that I broke my LLM virginity lately. I needed help with an obscure-ish library that assumes 100% proficiency in its domain to be used. Claude taught me how to use it and helped me troubleshoot a problem with the input data.
I still don’t view LLMs as killing programming – they are VERY long way from that – but I can’t deny that with the main search engines being near-useless, the LLMs fill some gaps well.
cmo
It is a Large Language Model, not a Large Problem Solving Model after all. A lot of people aren’t managing their own expectations very well when it comes to LLMs.
Last Post!
Awlexus
Why I don’t like the Zed AI integration, or AI integration in general
Prompting with reasoning models includes the whole thinking process, which makes for clunky integratation. Other models I tried would wrap the code in {{code}} occationally and I couldn’t really find any models that generate usable code for the things I asked.
Why I don’t like Zed itself
In terms of why I don’t like the editor, the shortcuts are impractical compared to the ones of the text editor and still require you to use the mouse every now and then. Additionally, many shortcuts simply don’t work under linux, which is an absolute dealbreaker.
The configuration being a json file for a graphical text editor is a thing I already heavily disliked for VS code.
Popular in Discussions
Other popular topics
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









