Questions tagged [elixir]

Elixir is a functional meta-programming aware language built on top of the Erlang VM. It is a dynamic language with flexible syntax with macros support that leverages Erlang's abilities to build concurrent, distributed, fault-tolerant applications with hot code upgrades.

Filter by
Sorted by
Tagged with
1 vote
0 answers
606 views

Recursive combinations with subsets in Elixir

...
Glutexo's user avatar
  • 111
0 votes
1 answer
54 views

SMTP client module

I'm new to elixir and would really like some feedback on my code. MY background has been node -> laravel -> ruby / rails -> go -> elixir. I'm building an SMTP client and would like to make ...
Quesofat's user avatar
  • 143
1 vote
1 answer
123 views

Retrieving first non-private ip for local system in elixir

I've recently started learning elixir, and the following is my attempt at fetching the local IP address of the system. It can definitely be improved further, but as this would be my first ever project ...
hjpotter92's user avatar
  • 8,706
1 vote
0 answers
227 views

Performing efficient batch inserts after batch inserts using Ecto.Multi

I have a transactional batch inserts where previous batch insert results will be used in another batch insert. My code below already works and just want to ask if there are part of the code to be ...
jeepers3327's user avatar
1 vote
0 answers
84 views

Metaprogamming elixir for module proxy

I'm working on my first real Elixir application, after dabbling for a few years. In my elixir/phoenix application I have to work with data over an external REST API. For my purposes, I can tolerate ...
Segfault's user avatar
  • 141
4 votes
1 answer
230 views

Elixir generate inverted / reversed map

I would like to transform the input elems = [a, b, c] terms = [t1, t2] @spec contains?(term, elem) :: boolean def contains?(term, elem), do: #implementation to ...
Mark McElroy's user avatar
1 vote
0 answers
74 views

Tic Tac Toe game logic

I've implemented tic-tac-toe in TypeScript before; now I'm porting it to Elixir. As before, this is pure game logic, no UI involved. I'm very new to Elixir, so any suggestions are appreciated. The ...
DylanSp's user avatar
  • 203
5 votes
0 answers
132 views

Scanning a string into a list of tokens

Here is my code: ...
dopatraman's user avatar
2 votes
1 answer
50 views

Naive SCP module in Elixir

I'm trying to do a simple implementation of a scp wrapper in Elixir. The code is working as intended, but I got a feeling that the error conditions can be ...
Rodrigo Ce Moretto's user avatar
2 votes
1 answer
83 views

Emulating the pipe operator in javascript in a readable way

In this article I found this quite elegant looking Elixir code: ...
oligofren's user avatar
  • 121
1 vote
1 answer
74 views

Find the sum of Fibonacci sequence

I have already done many of the Project Euler questions in other languages before, but whenever learning a new language, I like to do the problems again in that language. Here is my elixir version ...
Dylan's user avatar
  • 119
1 vote
1 answer
156 views

Expose encrypted serial ID in Elixir

I'm working on a Phoenix/Absinthe application and I thought to expose encrypted sequential IDs instead of UUIDs since these are a bit shorter. Encryption on Elixir/Erlang seems very hard, so I think I'...
emiliano.bovetti's user avatar
2 votes
0 answers
40 views

Spiral printing elements of a matrix

As I'm learning elixir, I wrote some code for printing elements in the spiral of a matrix(2D array). I was wondering if there is any room for improvements with regards to its performance or ...
Surya's user avatar
  • 121
1 vote
0 answers
41 views

Collect the values of a Map into a MapSet

...
QuestionC's user avatar
  • 111
1 vote
2 answers
372 views

Storing temporary data in ETS - for example, using ETS in a web wizard

I'm learning the Elixir language and the Phoenix web framework. And I had an idea. What if, in a web wizard (multi-step form) scenario, I stored the intermediate data in a ETS table instead of the ...
art-solopov's user avatar
3 votes
0 answers
91 views

Paginator module in Elixir

I wrote this Paginator module that's part of a small application that displays Elixir Github repos in a table. I'm new to Elixir and looking for code improvements with as much as possible. Best ...
dan-klasson's user avatar
6 votes
1 answer
113 views

String contains non-overlapping letter pairs

I was trying my hand at learning Elixir via ancient adventofcode puzzles and was trying to write a function to satisfy this requirement: It contains a pair of any two letters that appears at least ...
thesunneversets's user avatar
1 vote
2 answers
100 views

Extract and divide algorithm implementation in Elixir

I just started learning Elixir and stumbled upon this challenge over on Programming Puzzles & Code Golf. It is a well-suited task for beginners, so I chose to give it a go (to be clear, give it a ...
Mr. Xcoder's user avatar
3 votes
0 answers
418 views

Recursive solution for Longest Substring Without Repeating Characters written in Elixir

Here's my recursive implementation of a sliding window algorithm to find the longest substring of a given string without repeating characters. Is there a more idiomatic-Elixir way to write this? <...
Eli's user avatar
  • 31
4 votes
1 answer
474 views

Elixir PEG Parser Generator

I am trying to learn Elixir, so I decided to write a port of Ruby's Parslet library. I want to define a DSL that lets you define your grammar and given a string can parse it into an AST. I wrote ...
Nigel Thorne's user avatar
5 votes
1 answer
733 views

Get The Base Name of an Elixir Template File

I've got the following Elixir code: ...
Onorio Catenacci's user avatar
3 votes
0 answers
49 views

Elixir SQL Query Returning Structs or Counts

I have a few raw queries which are similar to each other in that it is mostly duplicate code with the difference being that one returns structs and the other returns counts of how many there are. How ...
DogEatDog's user avatar
  • 173
2 votes
0 answers
131 views

Grep kata in Elixir

I've written a simple grep program as my first foray into Elixir. Could you please suggest some ways in which the code could make better use of the language? ...
user1837378's user avatar
4 votes
1 answer
346 views

Elixir/Ecto find_or_create with custom error

I need to find_or_create user, but first, check if his email ends with a required domain. Can I somehow write following code using pattern matching with/case block?...
Ruslan Savenok's user avatar
3 votes
0 answers
120 views

GTIN Check Digit Validation in Elixir

Similar to other GTIN validations, the function should take the entire string of the read in barcode, calculate the check digit, and compare it to the check digit on the code. For example, the code <...
DogEatDog's user avatar
  • 173
1 vote
2 answers
3k views

Using Elixir pipeline to transform a string into a map

Consider the list of string values, lines = ["foo: 1", "bar: 2", "baz: 3"] That one might transform into the Elixir map, ...
ybakos's user avatar
  • 113
1 vote
1 answer
90 views

Elixir - Points bot using Ecto

I'm making a bot that will be used for "points" tracking and such, like a reward system and I'm using Ecto with postgrex, this is my approach so far, it works but I'...
Aguxez's user avatar
  • 147
2 votes
0 answers
93 views

Schizo kata in elixir

I just started picking up Elixir (I don't have any functional programming background either), I would appreciate any feedback you have! The kata is about writing two functions: ...
tpv's user avatar
  • 121
1 vote
1 answer
57 views

Rendering a payroll template

In a project I decided to parse a file and create functions during compilation to speed up rendering of a payroll template. I had (or still have?) a hard time grasping macros in Elixir so I started ...
toraritte's user avatar
  • 111
-1 votes
1 answer
1k views

Patten matching to check for non-empty argument list

I'm learning Elixir. while building a trivial cli application (as seen here http://asquera.de/blog/2015-04-10/writing-a-commandline-app-in-elixir/) I'm defining a module that implements a ...
G3z's user avatar
  • 117
5 votes
1 answer
826 views

Codewars kata : reverse and rotate

I just started to learn Elixir and to train on Codewars. I solved this kata but I'm not very satisfied of my code and I have no clue (literally) how to improve it. Recursion seems the way to go here, ...
JJP's user avatar
  • 153
1 vote
1 answer
181 views

Scoring Ping Pong in Elixir

I have some elixir code I am using to score a ping pong game. Since I am new to functional programming I was hoping there might be a more elegant solution to this. This part of the code is used in a ...
Dough's user avatar
  • 11
3 votes
0 answers
1k views

Hex to Binary Conversion

Just mucking around with Elixir and bitstrings and wondering if there is a better way to implement the following ( or improve ). :- ...
Keith Nicholas's user avatar
3 votes
1 answer
213 views

Elixir / Phoenix login controller, allowing multiple attempts

I have a login method in my controller. I would like to get rid of the imperative "thinking" and write something more functional. ...
Jeremie Ges's user avatar
6 votes
2 answers
1k views

Pattern matching deeply nested arguments in Elixir

I've recently started working with Elixir and am writing an app that queries various URLs and parses the response. I am having issues with my parse method, which is ...
Scott Swezey's user avatar
5 votes
1 answer
1k views

Count words in string and tally up the repetitive words

I'm an elixir beginner. I'm doing the word count exercise of exercism website. The word count exercise returns a map with the word as the key and the number of instances as value. The exercise ...
ltrainpr's user avatar
  • 263
2 votes
1 answer
937 views

Phone validation ecto model

...
Jeremie Ges's user avatar
1 vote
2 answers
84 views

Formatting a birthday in years

...
Jeremie Ges's user avatar
3 votes
1 answer
477 views

Tail Recursion for Sum - Elixir

I'm new to both Elixir and tail recursion. ...
Mouli's user avatar
  • 133
2 votes
0 answers
260 views

Converting Chess FEN Notation to a Tuple and Back

This module is going to be part of a larger ElixirChess library for validating chess positions and moves, but I started with the core of it which is parsing a ...
Ryan Lynch's user avatar
6 votes
1 answer
403 views

Chat room using GenServer

It seems odd that state must be passed around all the time. Can't State module hold itself, so I could do something like ...
roberts's user avatar
  • 61
2 votes
0 answers
132 views

Coloring trees in Elixir

The following is my tree coloring realisation attempted to get a feel of Elixir (simple, but slow coloring algorithm from Principles of Distributed Computing). Coloring runs from the root, using ...
Roman Susi's user avatar
4 votes
1 answer
914 views

Return a grouped sum from a list

I just started with Elixir and this is what I have now. Is there an easier or better way to write this? ...
Elixir Coder's user avatar
3 votes
1 answer
424 views

Simple/Naive Implementation of Identity and Maybe Monad in Elixir

This is my first crack at a identity monad and a maybe monad in Elixir: ...
Onorio Catenacci's user avatar
3 votes
0 answers
126 views

Phoenix Ecto schema for internal mailbox

I am building an application messaging system. I am planning on using channels for real-time notifications but I was wondering if this schema makes sense. I am looking for any constructive criticism ...
Arthur Collé's user avatar
2 votes
0 answers
284 views

Ascii85 in Elixir

I'm a complete newbie to Elixir, but I managed to bang together this working example of Ascii85 for a project I'm working on in my spare time. I find some awkward repetition in here which I have ...
Hakanai's user avatar
  • 121
5 votes
1 answer
309 views

Generating all valid dates

I've come up with the following code to generate a list of all dates between two given dates: ...
Onorio Catenacci's user avatar
5 votes
0 answers
250 views

War Game GenServer Implementation

One of the Etudes for Elixir exercises is to create a War game that uses the spawn, send, and ...
Havvy's user avatar
  • 181
9 votes
2 answers
555 views

Berlin clock kata in Elixir

I'm starting with Elixir and as exercise I wrote the Berlin Clock kata: The clock is made up of 5 rows. On the very top of the clock is a lamp that blinks to show the seconds. It turns on for one ...
ema's user avatar
  • 193
13 votes
1 answer
378 views

Multi-process FizzBuzz in Elixir

So I was playing with writing FizzBuzz in Elixir; this is my first, naive implementation: ...
Onorio Catenacci's user avatar