Questions tagged [elixir]

Elixir is an open-source, dynamic, compiled, general purpose functional programming language. It was designed to be fully compatible with the Erlang platform and is well suited to writing fault-tolerant, distributed applications with soft real-time guarantees and the ability for hot-code-swapping.

enter image description here

Elixir is an open-source, dynamic, compiled, general purpose functional programming language. It was designed to be fully compatible with the Erlang platform and is well suited to writing fault-tolerant, distributed applications with soft real-time guarantees and the ability for hot-code-swapping.

Elixir was designed with programmer productivity as a core concept and features:

  • Concise friendly syntax
  • Simple meta-programming with Macros
  • Scale facility and process orientation
  • Awesome documentation and testing built-in
  • Polymorphism with Protocols

Learning

Packages

Popular Elixir Projects

Books

Screencasts

Community

9482 questions
5
votes
2 answers

iex and erl starts very slow if not assign a node name

The environment is archlinux running in virtual machine. Erlang/OTP 17 [erts-6.2] [source] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false] Interactive Elixir (1.0.2) - press Ctrl+C to exit (type h() ENTER for help) If I run…
Kabie
  • 10,489
  • 1
  • 38
  • 45
5
votes
1 answer

How do I check for a Dictionary Type in Elixir

I want to check if the type of a parameter given to a function in Elixir is a Dictionary. How do I do this?
robkuz
  • 9,488
  • 5
  • 29
  • 50
5
votes
1 answer

How to start an OS process in Elixir

What's the best way to start an OS process in Elixir? I'd expect to be able to pass different parameters to it on start, capture its PID and then kill it.
cyberdot
  • 177
  • 1
  • 9
5
votes
1 answer

Elixir Plug Cowboy not using port 80

I have a Router plug defmodule Rest do use Plug.Router import Plug.Conn plug :match plug :dispatch get "/hello" do send_resp(conn, 200, "Hello, world!") end match _ do send_resp(conn, 404, "oops") end def start do …
lthreed
  • 444
  • 4
  • 11
5
votes
5 answers

Elixir - sum of list values with recursion

Just trying to do simple sum of list values. defmodule Mth do def sum_list([]) do 0 end def sum_list([H|T]) do H + sum_list(T) end end IO.puts Mth.sum_list([1, 2, 300]) But I get this…
Krab
  • 6,526
  • 6
  • 41
  • 78
5
votes
3 answers

static analysis vs static typing

I'm learning Elixir, and the tool 'dialyzer' lets you do static analysis - annotate the function definition with the type specification of the parameters it expects and the output it returns. It's completely optional, but if it were to be used to…
tldr
  • 11,924
  • 15
  • 75
  • 120
5
votes
1 answer

function '<-'/2 undefined Error in receive block Elixir

This is my Elixir code. defmodule ErlProcess do def receiver do receive do {:sayHello, msg}->sender<-{:ok, "ok"} end end end But it gives this error. ** (CompileError) spawn.exs:4: function '<-'/2 undefined …
Lahiru
  • 2,609
  • 3
  • 18
  • 29
5
votes
1 answer

Elixir default parameters for named functions with multiple clauses

I have trouble understanding how default parameters interact with multiple clauses in named functions. It boils down to, why does the following snippet work? defmodule Lists do def sum([], total \\ 0), do: total def sum([h|t], total), do: h +…
Alexander Battisti
  • 2,178
  • 2
  • 19
  • 24
5
votes
1 answer

Using of bracket syntax in Elixir record

I'm learning the Elixir programming with elixir lang getting started , and I'm stacked of the record brace syntax. This is the sample: defrecord FileInfo, atime: nil, accesses: 0 defmodule FileAccess do def was_accessed?(FileInfo[accesses: 0]),…
jsvisa
  • 2,987
  • 2
  • 24
  • 30
5
votes
1 answer

Warning "Redefining module" when file is containing 2 Modules

Trying to figure out why below code is generating warning defmodule A do def greet do IO.puts "Inside…
Jack Daniel's
  • 2,583
  • 22
  • 28
5
votes
1 answer

How to dynamically call an operator in Elixir

I'm working my way through Dave's upcoming book on Elixir, and in one exercise I would like to dynamically construct a function reference to Kernel.+/2, Kernel.-/2 etc, based on the contents of one character of a string, '+', '-' and so on. Based on…
Daniel Ashton
  • 1,388
  • 11
  • 23
5
votes
1 answer

Is there a way that we can reference the whole variable while in pattern matching of Elixir?

There is an as-pattern in Haskell, which allows us referencing the whole variable while in pattern matching: foo wholeList@(head:tail) = wholeList ++ head The variable wholeList represents the original variable. Assuming that head is ["Hello"],…
Noah Blues
  • 1,339
  • 2
  • 11
  • 19
5
votes
3 answers

Elixir's Range for arithmetic progression

Is it possible to express arithmetic progression in a list without listing them all? In Haskell, you could do it with the range function. [2,4..10] == [2,4,6,8,10] Is there a similar way to do it with Elixir ?
Kit Ko
  • 315
  • 2
  • 7
5
votes
1 answer

Implementing a protocol by delegating to existing functions

I'm learning Elixir by modeling a board game, and I have this code: defprotocol Board do def can_handle_move(self) def handle_move(self, move) end defimpl Board, for: List do def can_handle_move(self), do: Enum.empty?(self) def…
Hugo Wood
  • 2,140
  • 15
  • 19
4
votes
2 answers

How to properly create, observe and destroy lots of pre-defined jobs at runtime?

I plan to create a web service which will allow the users to spawn a large number, let's say 3k-5k, of certain types of jobs. There'll be a few different, pre-defined types of jobs. defmoudle Job1 do def do_work1(a, b, c) do end end defmoudle…
mondichuk
  • 77
  • 1
  • 5
1 2 3
99
100