theme: Merriweather2, 1
https://www.facebook.com/groups/elixir.tw/ https://www.meetup.com/Taipei-Elixir-Erlang-Meetup-Group/
C#1
300µs per process 50µs per message
1µs up to 2,500 processe 3µs up to 30,00 processes 0.8µs per message
process in Erlang/Elixir =~ object instance in OO application
We do not have ONE web-server handling 2 millions sessions. We have 2 million webservers handling one session each.2
- Joe Armstrong
defmodule Math do
def sum(a, b) do
a + b
end
end
Math.sum(1, 2) #=> 3
x = 1
# Ruby x, x, y = [1, 2, 3] # => x = 2, y = 3
[x, x, y] = [1, 2, 3] # => Error
[x, x, y] = [1, 1, 3] # => x = 1, y = 3
{m, "bar", n} = {"foo", "bar", "baz"} => m = "foo", n = "baz"
defmodule Factorial do
def calc(0), do: 1
def calc(val), do: val * calc(val - 1)
end
Factorial.calc(100)
def parse(html =
%{head: head = %{title: title, meta: _},
body: body})
when is_bitstring(title) do
# body => "Hello world"
# title => "foo"
# head => %{title: "foo", meta: "bar"}
# html => %{head: %{title: "foo", meta: "bar"}, body: "Hello world"}
end
parse(%{head: %{title: "foo", meta: "bar"}, body: "Hello world"})
response = get_response(request)
body = parse_body(response, :html)
html = render(body)
html = render(parse_body(get_response(request), :html))
html =
request
|> get_response()
|> parse_body(:html)
|> render()
Enum
:map
,reduce
,filter
,zip
,scan
Stream
: lazy evaluation
GenServer
,Supervisor
Task
: Partially GenServerAgent
: Another side of GenServerFlow
: Back-preasure concurrent base on GenState
The ability to manipulate AST
iex> quote do: 1 * 2 + 3
{:+, [context: Elixir, import: Kernel],
[{:*, [context: Elixir, import: Kernel], [1, 2]}, 3]}
defmodule Num do
@doc """
Demonstrate doctest feature
## Example
iex> Num.is_even?(1)
true
"""
def is_even?(num) do
rem(num, 2) == 0
end
end
TODO: mickey
https://github.com/nerves-project
.
├── firmware
│ ├── _build
│ ├── config
│ ├── deps
│ ├── lib
│ ├── mix.exs
│ └── mix.lock.rpi3
└── ui
├── assets
├── config
├── deps
├── lib
├── mix.exs
└── priv
export MIX_TARGET=rpi3
mix deps.get
mix firmware
mix firmware.burn
{:nerves_firmware_http, "~> 0.4"}
mix firmware.push 192.168.1.100 --target rpi3
-
Elixir.tw Facebook:
-
Elixir.tw slack: https://elixirtw.herokuapp.com/
-
Elixir slack
-
Pragmatic bookshelf
-
Manning
Footnotes
-
2003's data ↩