loganhelms
Any resources to learn about memoization in Elixir?
A while back, I read a great book by Luis Atencio titled, Functional Programming in JavaScript. In section 7.3, he discusses memoization (an optimization technique for caching output values for pure functions for optimization).
If this is already part of Elixir, could someone point me to where I can learn more about it?
If it is not part of Elixir, is there a discussion for its value and tradeoffs?
Most Liked
bryanhuntesl
Trade off is memory consumption/local disk cache/staleness/invalidation
5
Sebb
4
cjbottaro
You don’t even need a process to manage state for memoization. Just need to change your API a little bit.
Stateful Ruby…
class Foo
def blah
@blah ||= calc_blah()
end
end
Stateless Elixir…
module Foo do
def blah(obj) do
if obj.blah do
{obj.blah, obj}
else
blah = calc_blah(obj)
{blah, %{obj | blah: blah}}
end
end
end
3
bryanhuntesl
2
Popular in Chat/Questions
https://e.planaria.network/stack.png
https://e.planaria.network
Build a NoSQL DB, Build a Relational SQL Database, Build a Graph Datab...
New
Besides Basic types - The Elixir programming language are there any other well recommended “elixir by example” style resources / books ? ...
New
hello from a real frustrated newbe…
I’m reading this article Full-Stack React With Phoenix (Chapter 3 | Introduction to Phoenix) by mich...
New
I’d like to provide my review of the Elixir Course module from Groxio. I have some criticisms but I’d like to start with the positives.
...
New
Hi Everyone,
I am a student and know basics of web development, used some php and ruby, but I am not an expert in any. I want to learn E...
New
Hi sasajuric, any chance of a fresh promo code? :sunglasses:
New
Hey, I have very restricted resources and time so I’m trying to understand the best way to learn Liveview in terms of cost/time.
The Pra...
New
Hi!
In my quest of becoming the best Elixir dev I can be, I saw one aspect in my
career that I’d like to improve upon. This is language...
New
Background
After following the communitiy suggestion, I bought the Elixir in Action 2nd Edition book and I am about to finish it now.
I ...
New
Hi, I was looking for a pointer of how I could most easily start with phoenix regarding deploying it to something like linode or google c...
New
Other popular topics
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New








