Questions tagged [erlang]

Erlang is a general-purpose programming language and runtime environment. It has built-in support for concurrency, distribution and fault tolerance. Erlang is used in several large telecommunication systems from Ericsson. Erlang is open source and available for download on GitHub.

Filter by
Sorted by
Tagged with
2 votes
0 answers
59 views

Erlang: Seeking advice on BEST practices with ETS table manager

I wrote a some what "simple" module to retain ETS tables should the owner crash. I think it's small enough for review; big enough to make enough mistakes. Honestly I'm a hobbyist programmer ...
user avatar
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
778 views

Uninstalling Erlang and RabbitMQ, using Write-Verbose to ensure sequencing

I'm new at PowerShell and I like it. I had the change to write a script that uninstall Erlang and RabbitMQ and I want the same script to then remove the Erlang folder and the RabbitMQ folder. But ...
user avatar
4 votes
1 answer
48 views

Error handling for an Erlang 2D point class

I am working on a math library for an online game. I want to prevent as many errors as possible and I want to catch all errors as early as possible to simplify debugging in the long run. However, I ...
user avatar
  • 147
1 vote
1 answer
163 views

Managing many exceptions in Erlang cowboy without deeply nested trees

In my cowboy (Erlang) application, I have a handler called projects_from_json. This takes a JSON POST request as input and ...
user avatar
2 votes
0 answers
201 views

A simple tokenizer in Erlang

I'm trying to learn Functional Programming and I picked Erlang because I will have to use it eventually. In the meantime, I'm trying to build a simple lexer to stumble upon problems and solve them ...
user avatar
3 votes
1 answer
46 views

Order loaded modules by amount of functions

I am trying to solve some exercises from the "Programming Erlang" book. One of them is "Write a function to determine which module exports the most functions" This is my solution: ...
user avatar
2 votes
1 answer
71 views

Move zeroes to the end of array

For the problem of moving zeroes to the back of the array as detailed here. I did it like below in Erlang. I just think my way is very basic and probably there is a more elegant way to do it using ...
user avatar
2 votes
1 answer
344 views

Erlang: pmap with max number of processes

I'm working through Joe Armstrong's Programming Erlang 2nd E. The book has exercises at the end of each chapter. Chapter 26, Question 5 is: Write a function called ...
user avatar
1 vote
1 answer
268 views

Find the sum of the digits in factorial of 100 in Erlang

This is a problem in poject Euler: n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 ...
user avatar
  • 113
1 vote
1 answer
308 views

Priority queue in Erlang

I'm new to Erlang and I'm trying to port my Project Euler solutions in C# to Erlang. I have a priority queue implementation with unit tests. I'm wondering if I'm missing something(I probably do) if ...
user avatar
3 votes
0 answers
111 views

Recursive Blum Blum Shub

Since my last tattoo resulted in a syntax error I was thinking of getting it peer reviewed this time around, are there any errors or quirks with this recursive Blum Blum Shub implementation that I ...
user avatar
  • 131
0 votes
1 answer
109 views

Simple logger for a server

I wrote a simple logger for a server I'm writing. I'm wondering if anyone has any suggestions to improve it. doom_logger.erl ...
user avatar
  • 103
3 votes
1 answer
263 views

Killing and restarting processes

I am a beginner with Erlang and currently making my way through the awesome Joe Armstrong's book. The following are my answers to exercises 5 and 6 for the concurrency chapter. The code can probably ...
user avatar
  • 33
3 votes
1 answer
674 views

Erlang process pool

I am coming from Java and I am trying to create a process pool in Erlang. Like the Java API: ...
user avatar
4 votes
1 answer
321 views

Simple Rock Paper Scissors in Erlang

I'm very new to Erlang and I'm specifically interested in making my Erlang idiomatic (in other words, can you tell I don't know Erlang from this code?) and removing code duplication. I am not as ...
user avatar
5 votes
1 answer
113 views

Cleaning up Erlang code for a text editor

On Monday and Tuesday I started learning Erlang through the Erlang Koans, and around Wednesday night I decided to use my newfound knowledge to implement a simple text editor (Akin to ed(1)). Currently ...
user avatar
  • 153
3 votes
1 answer
336 views

Sleeping barber problem in Erlang

I'm learning Erlang. It's my first time with a non-imperative programming language. I've written a code and I want some thoughts about it: Is my logic easy to understand? Is my code idiomatic? Is my ...
user avatar
  • 993
3 votes
1 answer
186 views

Short Erlang function to demonstrate hd and tl

I'm simultaneously learning Erlang and writing a short guide on list operations. Here is a trivial function I wrote to demonstrate hd and tl: ...
user avatar
  • 31
4 votes
2 answers
230 views

Sieve of Eratosthenes in Erlang

I just started learning Erlang. Here is my crack at the Seive, based on (https://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf): ...
user avatar
  • 139
3 votes
2 answers
702 views

Hackerrank challenge - Dictionaries and Maps in Erlang

This question is really similar to an existing one in Ruby. So the task is also the same: Day 8: Dictionaries and Maps! The problem is that on Hackerrank my solution only passes the first and last ...
user avatar
  • 133
2 votes
0 answers
176 views

Erlang linter written in Erlang using erl_lint:module

I've just started learning Erlang. Since my editor of choice doesn't have a syntax checker for Erlang, I decided to use the parser/linter in the standard library to make a standalone script. It works ...
user avatar
  • 201
3 votes
3 answers
503 views

MapReduce in Erlang

I'm doing a comparison of Erlang, Haskell, Elixir and ES6, and I'm less farmiliar with Erlang and Elixir, but I want to represent all of these languages fairly, so is this good Erlang code? ...
user avatar
1 vote
1 answer
87 views

Coins problem in Erlang

How many different ways can 200 be made using any number of coins? The possible denominations are 1, 2, 5, 10, 20, 50, 100, 200. ...
user avatar
3 votes
1 answer
172 views

Lattice traversal functional algorithm

I have the following code which returned the solution I was wanting after running for 1 hour. Are there any techniques I could use to improve run-time? If I were using imperative programming I would ...
user avatar
  • 283
6 votes
3 answers
420 views

Erlang treasure hunt

I have the following task: Create a simple treasure hunt game. Create a two-dimensional array of integers 10 by 10. In a random position in the array store the number 1. repeat Get the ...
user avatar
  • 317
1 vote
1 answer
536 views

Erlang parallel server using sockets

The task was to build a simple parallel server in erlang that prints what it receives through a socket and alerts when the socket is closed. ...
user avatar
  • 317
3 votes
1 answer
114 views

Erlang handling errors in concurrent programs

I have two tasks: Write a function that starts and monitors several worker processes. If any of the worker processes dies abnormally, restart it Here is the code that I built: ...
user avatar
  • 317
2 votes
1 answer
125 views

Parsing user name and password from binary in Erlang + Cowboy

I am working on a web app that uses a WebSocket to log in users. I would like to minimize bandwidth usage by using binary messages. I came up with the following, and would like to know whether there ...
user avatar
  • 201
4 votes
1 answer
1k views

Tic-Tac-Toe game using erlang gen_fsm

I would like to use erlang to create an online, web-based game. I thought it would make sense to start with something easy, so I chose tic-tac-toe (which seems like a popular choice here). I am ...
user avatar
  • 201
3 votes
1 answer
142 views

Erlang pattern matching excersise

I recently started my first project with Erlang. I've been skimming documentation and various books to get the information I need, and it's going well, but now that I have something that works I want ...
user avatar
3 votes
2 answers
2k views

Is there a better way to write these two nested loops in Erlang?

Since one month, I'm learning Erlang and I like it so much. Today, I wrote an algorithm to solve a problem. Some time ago, I used two nested for loops in C# to ...
user avatar
11 votes
1 answer
919 views

Genetic algorithm for "Hello World"

I've written an Erlang implementation of the genetic algorithm for a "Hello World" program as described here. This is my first time writing any code in Erlang and also my first time writing code in a ...
user avatar
7 votes
1 answer
276 views

Improving clarity and style of this "Document at a time" algorithm

I've created a module that implements a basic "Document at a time" algorithm for inverted index querying (more background here). There are many algorithm improvements possible, but I'm now interested ...
user avatar
2 votes
3 answers
439 views

Slow Erlang code to find Pythagorean triplets

Why does this Erlang code take about one minute on my machine? On Pascal something like this took less then second on my machine. What I can do to speed it up? ...
user avatar
1 vote
1 answer
114 views

Feedback on Erlang Lists processing function

I have just started learning erlang...I am just practicing the recursion and all in erlang...I tried to write a few of the list processing functions on my own in erlang...Can someone review the code ...
user avatar
1 vote
3 answers
977 views

List-flattening function in erlang feels too wordy

I wrote a tail-recursive list-flattening function, but I'm not too happy with it. a) Is tail-recursion necessary here, or will the function be optimized without it? b) It's ugly how many clauses ...
user avatar
  • 111
2 votes
2 answers
291 views

Arithmetic progression to 7561

I'm new to Erlang and this is my first code in that. As Erlang has no loop statements, the only way I could think of doing this is as follows: ...
user avatar
  • 131
2 votes
1 answer
402 views

Erlang FFI into ImageMagick

This is a short program meant to give me an Erlang hook into the ImageMagick FFI for performance reasons. All comments welcome, but specifically my C experience is minimal, bordering on ...
user avatar
  • 2,173
1 vote
1 answer
204 views

Erlang code that generates text output

I have recently made a small program to generate D&D (original edition) monster stat blocks in text form. I use this program myself to generate stats block so that I can then copy and paste them ...
user avatar
  • 347
5 votes
2 answers
296 views

Take a number and return English language representation

Like many, I started out with procedural programming. Of course, when learning a functional language, old habits may die hard, so I wrote a fairly trivial little thing which takes an integer and ...
user avatar
11 votes
3 answers
539 views

Erlang concurrency in circles

I am new to erlang (2 days to be honest) and I would highly appreciate some peer review. I am doing these exercises and was a bit stuck at this point: 2) Write a function which starts N processes ...
user avatar
6 votes
1 answer
998 views

Newbie Map/Reduce word frequency counter

I present you my first ever module to learn some Erlang awaiting your scrutiny . It does a word frequency count using map/reduce . I'm an Erlang noob, so I would very much like feedback about: ...
user avatar
7 votes
2 answers
1k views

Erlang code to list all IP addresses

This is some Erlang code I wrote to output a string of all the IP addresses of the machine. The string is simply printed to the user for him to read. ...
user avatar
  • 873