08. Dezember 2013
Falco Hirschenberger
Das will ich auch lernen!
“Erlang is a declarative, dynamically-typed, functional, concurrent, distributed and fault-tolerant programming language with garbage collection and code hot-swapping built into its soft-realtime runtime system.”
Ok, alles klar? Fertig.
Joe Armstrongbei Ericsson
Agner Krarup Erlangoder bedeutet einfach Ericsson language
Agner Krarup Erlang | Joe Armstrong |
Also wie geschaffen für unsere Inspektionssysteme
Also nichts für unsere Algorithmiker
The world is concurrent: things in the world don't share data, things communicate with messages, things fail.
-- Joe Armstrong
Let it crash!
KISS - Keep It Simple Stupid.
% read a file
{ok, Data} = file:read_file("/home/masc/ofiProtokoll.rst").
% sum up the size of all PNG files in a directory recursively.
filelib:fold_files("/home/masc/images", "*.png", true,
fun(File, Acc) ->
filelib:file_size(File) + Acc
end, 0).
% call function every second
timer:apply_interval(1000, io, format, ["Hello World"]).
% send a message to another process in the same VM
graph_runner ! {run_graph, [Img1, Img2]},
% send a message to a process on another computer
{masc@worker1, graph_runner} ! {run_graph, [Img1, Img2]},
receive
{result, ResultImg} -> ResultImg
end.
-module(evaluate).
-export([do_evaluate/4]).
do_evaluate(Img, FromPid, No, Width) ->
T1 = now(),
Graph = load_graph(graph_file),
case graph_runner:run_graph(Graph, [Img, Width, 1]) of
{results, Res} ->
% notify the collector of a new result
FromPid ! {new_result, Res, No},
lager:info("Graph time: ~p",
[timer:now_diff(now(), T1)/1000]);
{error, R} ->
lager:error("Evaluation error: ~p", [R]),
% notify the collector of an evaluation error
FromPid ! {error, R, No}
end.
Eshell V5.10.3 (abort with ^G)
1> Txt = "Hallo" ++ " Welt".
"Hallo Welt"
2> Txt = Txt ++ "!".
** exception error: no match of right hand side value "Hallo Welt!"
map, fold, foreach
)
Eshell V5.10.3 (abort with ^G)
3> lists:foldl(fun(N, Acc) -> N + Acc end, 0, lists:seq(1,100)).
5050
Stüken
Xella
Das will ich auch lernen!
Pah! Das will ich nicht lernen!