Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
2answers
144 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
6 views

Nested conversion

I wrote this module that converts json to a nested structure based on its parent id. Takes this json input: ...
3
votes
0answers
39 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 ...
3
votes
1answer
32 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
2answers
32 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 ...
4
votes
0answers
217 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? <...
4
votes
1answer
212 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 ...
5
votes
1answer
71 views

Get The Base Name of an Elixir Template File

I've got the following Elixir code: ...
2
votes
0answers
35 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 ...
2
votes
0answers
60 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
49 views

invariants in a Quixir property test

I've implemented the following prop. test: ...
3
votes
1answer
185 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?...
3
votes
0answers
58 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
2answers
960 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
59 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
67 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: ...
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 ...
0
votes
1answer
215 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
560 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, ...
1
vote
1answer
140 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 ...
2
votes
0answers
761 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 ). :- ...
3
votes
1answer
106 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. ...
6
votes
2answers
695 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
772 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 ...
1
vote
0answers
57 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: ...
2
votes
1answer
571 views
1
vote
2answers
75 views
3
votes
1answer
323 views

Tail Recursion for Sum - Elixir

I'm new to both Elixir and tail recursion. ...
2
votes
0answers
143 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
237 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 ...
2
votes
0answers
101 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 ...
3
votes
1answer
537 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? ...
3
votes
1answer
293 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: ...
3
votes
0answers
120 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 ...
2
votes
0answers
181 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
245 views

Generating all valid dates

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

War Game GenServer Implementation

One of the Etudes for Elixir exercises is to create a War game that uses the spawn, send, and ...
1
vote
0answers
95 views

List filtering method

How can I make this more functional? ...
9
votes
2answers
422 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 ...
13
votes
1answer
324 views

Multi-process FizzBuzz in Elixir

So I was playing with writing FizzBuzz in Elixir; this is my first, naive implementation: ...
5
votes
2answers
752 views

How could this be written using continuation passing style?

Is there a way to use CPS in this code to make the two insert functions tail-call optimized? ...
5
votes
3answers
2k views

How Does This Naive Stack Implementation Look?

Consider this naive stack implementation in Elixir: ...
5
votes
2answers
195 views
7
votes
1answer
702 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
406 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. ...