cgrothaus
3 different ways to build a list with conditional elements in Elixir (and what that has to do with application startup)
I wrote a blog post about 3 different ways to build a list with conditional elements in Elixir (and what that has to do with application startup).
Most Liked
Eiji
There are other ways to achieve such results for example using recursive functions.
defmodule Example do
def sample(list) do
List.foldr(list, [], fn
{false, _child_spec}, acc -> acc
{true, child_spec}, acc -> [child_spec | acc]
child_spec, acc -> [child_spec | acc]
end)
end
def sample2([]), do: []
def sample2([{false, _child_spec} | rest]), do: sample2(rest)
def sample2([{true, child_spec} | rest]), do: sample2([child_spec | rest])
def sample2([child_spec | rest]), do: [child_spec | sample2(rest)]
end
input = [:not_tuple, {false, :skip_me}, {true, :no_skip}]
Example.sample(input)
Example.sample2(input)
Helpful resources:
2
Popular Backend topics
I dabbled in Phoenix for a while now, but never really got my hands dirty with it right up until now. Apart from the whole framework bein...
New
Interested in a blazingly fast type checker with 25 years of investment, delivered on the BEAM? Check out Caramel, an exciting project fr...
New
Rails Best Practices I.
Today I share some of my favorite practices applicable to Ruby on Rails (and to web development on small teams g...
New
Post on using UDP multicasting with Elixir to broadcast presence, and listen for peers, on a local network. I have found this approach us...
New
Following up on the previous post on using UDP multicasting to broadcast and detect peers on a network, I create a registry of those peer...
New
They expect you to make a onepage application (SPA)
The polaris design system officially only supports react
Integration with the s...
New
Charles Max Wood takes the lead this week. He and Adi Iyengar discuss what Top End Devs are and what people should be doing to become Top...
New
When DoorDash approached the limits of what our Django-based monolithic codebase could support, we needed to design a new stack that woul...
New
Does the world need another How to create a blog article?
Maybe not.
But then again, creating something out of nothing is what we love....
New
Peeper is the tiny library to preserve state across GenServer crashes/restarts.
Works as an almost drop-in substitute for GenServer, sui...
New
Other popular topics
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
New
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
New
Biggest jackpot ever apparently! :upside_down_face:
I don’t (usually) gamble/play the lottery, but working on a program to predict the...
New
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
Programming Ruby is the most complete book on Ruby, covering both the language itself and the standard library as well as commonly used t...
New
Will Swifties’ war on AI fakes spark a deepfake porn reckoning?
New
A Brief Review of the Minisforum V3 AMD Tablet.
Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New
Hello,
I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New
This is a very quick guide, you just need to:
Download LM Studio: https://lmstudio.ai/
Click on search
Type DeepSeek, then select the o...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /python
- /js
- /rails
- /security
- /go
- /swift
- /vim
- /clojure
- /emacs
- /haskell
- /java
- /svelte
- /onivim
- /typescript
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /flutter
- /vscode
- /ash
- /html
- /opensuse
- /centos
- /php
- /deepseek
- /zig
- /scala
- /sublime-text
- /lisp
- /textmate
- /react-native
- /debian
- /nixos
- /agda
- /kubuntu
- /django
- /arch-linux
- /deno
- /revery
- /nodejs
- /ubuntu
- /spring
- /manjaro
- /diversity
- /lua
- /julia
- /markdown
- /c








