yooncon

yooncon

Algo - a Ramda.js-like library of utility functions

Ramda is a popular FP utility library for JavaScript. I’ve made Algo in a similar vein for Elixir.

Elixir already has an excellent standard library, and Enum along with Kernel.put_in and related functions go a long way. But I found that it’s still less than trivial to do a lot of transformations when working with nested maps and keyword lists, deep-merging data, or chunking lists based on adjacent elements. I haven’t found an Elixir library that conveniently packages all of that like Ramda, so I made Algo.

The idea is to replace common, boilerplatey code with more compact, more descriptive functions. For example, you could transform some nested map values like this:

normalised_user = Algo.evolve(user, %{
  profile: %{
    age: &String.to_integer/1
  },
  metadata: %{
    score: &round/1
  }
})

There are also functions like deep_merge_right for deep merging, each_depth_first for a depth-first traversal, and so on. The functions for nested data structures work on both maps and keyword lists.

Additionally, there is a bunch of functions for working with lists, for example:

iex> Algo.List.chunk_while_adjacent([1, 2, 3, 1, 2], fn left, right -> right == left + 1 end)
[[1, 2, 3], [1, 2]]

iex> Algo.List.get_permutations([1, 2, 3])
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]

I hope it’s useful.

Blog post with more details and examples: https://korban.net/posts/2026-05-20-algo-ramda-like-elixir-package

Docs: https://hexdocs.pm/algo
Hex package: https://hex.pm/packages/algo

Repo:

Most Liked

scivi

scivi

I am curious: why did you implement both verb-style and result-noun-style functions? I would strongly prefer the latter as well, and have advocated for that even in Ruby projects.

FlyingNoodle

FlyingNoodle

In addition to this I don’t like all the alias for different functions. There is intersection_by/3 which is just an alias for intersect_by/3. If I want to refactor something I have to remember to grep for all alias versions of the same function.

FlyingNoodle

FlyingNoodle

Since I’m working on an application with lots of other developers I can 100% guarantee that people would choose ALL the different flavours of any given function.

Where Next?

Popular in Announcing Top

tmbb
I’ve published the first version of my Makeup library. It’s a syntax highlighter for Elixir in the spirit of Pygments, Currently it highl...
New
asiniy
Hey there! I wrote a download elixir package which does exactly what its name about - an easy way to download files. I saw solutions ab...
New
dominicletz
Hi, I thought I had posted my library before but seems I hadn’t. The project is still in early stages but it’s growing and so I think it...
New
maltoe
Hello! Came here to announce ChromicPDF, a pet project PDF generator I’ve been working on for the past few months. Why another PDF gener...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
Azolo
Hey everyone, I just released WebSockex which is a Elixir WebSocket client. WebSockex strives to work as a OTP special process, be RFC6...
New
archan937
It is a well-know topic within the Elixir community: “To mock or not to mock? :)” Every alchemist probably has his / her own opinion con...
New
markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New
tmbb
I’ve decided to create this topic to discuss optimization possibilities for something like Phoenix LiveView. I’ve created this topic unde...
144 10462 141
New
wfgilman
I’ve cleaned up and open sourced three financial libraries I was using for my company. They are bindings for the APIs of these three comp...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement