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
4
votes
1answer
24 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 ...
1
vote
0answers
39 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 ...
5
votes
0answers
101 views

Scanning a string into a list of tokens

Here is my code: ...
2
votes
1answer
36 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 ...
2
votes
1answer
57 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
59 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 ...
1
vote
1answer
123 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'...
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 ...
1
vote
0answers
28 views

Collect the values of a Map into a MapSet

...
1
vote
2answers
249 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 ...
3
votes
0answers
54 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 ...
6
votes
1answer
67 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
45 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
342 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
346 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
272 views

Get The Base Name of an Elixir Template File

I've got the following Elixir code: ...
3
votes
0answers
43 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
82 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
67 views

invariants in a Quixir property test

I've implemented the following prop. test: ...
4
votes
1answer
255 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
70 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
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, ...
1
vote
1answer
71 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
32 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 ...
2
votes
0answers
83 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
49 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
405 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
705 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
151 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
991 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
135 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
945 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
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 ...
1
vote
0answers
67 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
785 views

Phone validation ecto model

...
1
vote
2answers
82 views

Formatting a birthday in years

...
3
votes
1answer
364 views

Tail Recursion for Sum - Elixir

I'm new to both Elixir and tail recursion. ...
2
votes
0answers
172 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
280 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
108 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 ...
4
votes
1answer
745 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
347 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
123 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
212 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
262 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
196 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
96 views

List filtering method

How can I make this more functional? ...
9
votes
2answers
510 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
341 views

Multi-process FizzBuzz in Elixir

So I was playing with writing FizzBuzz in Elixir; this is my first, naive implementation: ...
5
votes
2answers
837 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? ...