Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
0 votes
1 answer
37 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 ...
user avatar
  • 143
1 vote
1 answer
58 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 ...
user avatar
  • 8,673
1 vote
0 answers
110 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 ...
user avatar
1 vote
0 answers
51 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 ...
user avatar
  • 159
4 votes
1 answer
144 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 ...
user avatar
1 vote
0 answers
67 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 ...
user avatar
  • 203
5 votes
0 answers
116 views

Scanning a string into a list of tokens

Here is my code: ...
user avatar
2 votes
1 answer
43 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 ...
user avatar
2 votes
1 answer
71 views

Emulating the pipe operator in javascript in a readable way

In this article I found this quite elegant looking Elixir code: ...
user avatar
  • 121
1 vote
1 answer
67 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 ...
user avatar
  • 119
1 vote
1 answer
145 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'...
user avatar
2 votes
0 answers
36 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 ...
user avatar
  • 121
1 vote
0 answers
34 views

Collect the values of a Map into a MapSet

...
user avatar
  • 111
1 vote
2 answers
342 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 ...
user avatar
3 votes
0 answers
72 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 ...
user avatar
6 votes
1 answer
90 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 ...
user avatar
1 vote
2 answers
83 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 ...
user avatar
3 votes
0 answers
391 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? <...
user avatar
  • 31
4 votes
1 answer
441 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 ...
user avatar
5 votes
1 answer
618 views

Get The Base Name of an Elixir Template File

I've got the following Elixir code: ...
user avatar
3 votes
0 answers
47 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 ...
user avatar
  • 173
2 votes
0 answers
117 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? ...
user avatar
1 vote
0 answers
68 views

invariants in a Quixir property test

I've implemented the following prop. test: ...
user avatar
  • 111
4 votes
1 answer
323 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?...
user avatar
3 votes
0 answers
104 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 <...
user avatar
  • 173
1 vote
2 answers
2k 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, ...
user avatar
  • 113
1 vote
1 answer
85 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'...
user avatar
  • 147
1 vote
0 answers
33 views

Basic structure of commandline applications

I am new to Elixir and experimenting a bit with my knowledge so far. I wrote a skeleton for a basic commandline application and I am looking for feedback (e.g. whether the code is ideomatic). The code ...
user avatar
  • 2,030
2 votes
0 answers
90 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: ...
user avatar
  • 121
1 vote
1 answer
54 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 ...
user avatar
  • 111
-1 votes
1 answer
919 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 ...
user avatar
  • 117
5 votes
1 answer
787 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, ...
user avatar
  • 153
1 vote
1 answer
164 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 ...
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 ). :- ...
user avatar
3 votes
1 answer
186 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. ...
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 ...
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 ...
user avatar
  • 263
1 vote
0 answers
81 views

Phoenix/Ecto: Update associated fields

I have this model: schema "jobs" do field :name, :string has_many :shiptos, MosaicApi.ShipTo end I want to update the shiptos associated with a job: ...
user avatar
  • 203
2 votes
1 answer
895 views

Phone validation ecto model

...
user avatar
1 vote
2 answers
83 views

Formatting a birthday in years

...
user avatar
3 votes
1 answer
439 views

Tail Recursion for Sum - Elixir

I'm new to both Elixir and tail recursion. ...
user avatar
  • 133
2 votes
0 answers
210 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 ...
user avatar
6 votes
1 answer
369 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 ...
user avatar
  • 61
2 votes
0 answers
124 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 ...
user avatar
4 votes
1 answer
856 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? ...
user avatar
3 votes
1 answer
389 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: ...
user avatar
3 votes
0 answers
125 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 ...
user avatar
2 votes
0 answers
267 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 ...
user avatar
  • 121
5 votes
1 answer
281 views

Generating all valid dates

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

War Game GenServer Implementation

One of the Etudes for Elixir exercises is to create a War game that uses the spawn, send, and ...
user avatar
  • 171