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
1answer
43 views

Emulating the pipe operator in javascript in a readable way

In this article I found this quite elegant looking Elixir code: ...
1
vote
1answer
87 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'...
1
vote
1answer
50 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 ...
2
votes
0answers
35 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 ...
3
votes
1answer
44 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 ...
1
vote
0answers
26 views
3
votes
0answers
48 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 ...
1
vote
2answers
187 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 ...
0
votes
0answers
10 views

Nested conversion

I wrote this module that converts json to a nested structure based on its parent id. Takes this json input: ...
1
vote
2answers
36 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 ...
3
votes
0answers
40 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 ...
5
votes
1answer
118 views

Get The Base Name of an Elixir Template File

I've got the following Elixir code: ...
4
votes
1answer
253 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 ...
3
votes
0answers
271 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? <...
2
votes
0answers
69 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? ...
1
vote
0answers
55 views

invariants in a Quixir property test

I've implemented the following prop. test: ...
4
votes
1answer
216 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?...
1
vote
2answers
1k 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, ...
1
vote
1answer
46 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 ...
9
votes
2answers
447 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 ...
1
vote
1answer
143 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 ...
3
votes
0answers
61 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 <...
1
vote
1answer
62 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'...
1
vote
0answers
31 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 ...
2
votes
0answers
73 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: ...
3
votes
1answer
113 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. ...
3
votes
0answers
121 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 ...
1
vote
0answers
61 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: ...
0
votes
1answer
252 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 ...
5
votes
1answer
626 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, ...
3
votes
1answer
315 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: ...
5
votes
3answers
2k views

How Does This Naive Stack Implementation Look?

Consider this naive stack implementation in Elixir: ...
2
votes
0answers
868 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 ). :- ...
6
votes
2answers
800 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 ...
5
votes
1answer
880 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 ...
3
votes
1answer
340 views

Tail Recursion for Sum - Elixir

I'm new to both Elixir and tail recursion. ...
1
vote
2answers
80 views
2
votes
1answer
661 views
2
votes
0answers
151 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 ...
6
votes
1answer
251 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 ...
4
votes
1answer
634 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? ...
2
votes
0answers
102 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 ...
2
votes
0answers
189 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 ...
5
votes
1answer
254 views

Generating all valid dates

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

Fetching environment variables — can I use pattern matching?

I've got the following Elixir code: ...
1
vote
0answers
95 views

List filtering method

How can I make this more functional? ...
4
votes
0answers
185 views

War Game GenServer Implementation

One of the Etudes for Elixir exercises is to create a War game that uses the spawn, send, and ...
7
votes
1answer
714 views

Elixir pipes and anonymous functions

I recently got started with Elixir. I'm used to F#'s pipes, and Seq.map and LINQ's .Select statements. Things are different in ...
10
votes
1answer
433 views

Roman numeral kata in Elixir

I'm new to Elixir, and in order to learn the syntax, I'm doing a roman numeral kata which converts a decimal number into roman numeral. I would appreciate any feedback you have. ...
13
votes
1answer
333 views

Multi-process FizzBuzz in Elixir

So I was playing with writing FizzBuzz in Elixir; this is my first, naive implementation: ...