Skip to content

Commit f206f3b

Browse files
authored
Create elchemy.ex
1 parent d504771 commit f206f3b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

elixir/elchemy.ex

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Compiled using Elchemy v0.7.4
2+
defmodule Main do
3+
use Elchemy
4+
5+
6+
@spec run() :: String.t
7+
def run() do
8+
"Hello, world!"
9+
end
10+
11+
@type action :: :inc | :dec | :double | {:mul, integer} | {:add, integer} | {:sub, integer}
12+
13+
@type state :: integer
14+
15+
@spec update(action, state) :: state
16+
curry update/2
17+
def update(action, state) do
18+
case action do
19+
:inc ->
20+
(state + 1)
21+
:dec ->
22+
(state - 1)
23+
:double ->
24+
(state * 2)
25+
{:mul, n} ->
26+
(state * n)
27+
{:add, n} ->
28+
(state + n)
29+
{:sub, n} ->
30+
(state - n)
31+
end
32+
end
33+
34+
end

0 commit comments

Comments
 (0)