Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Erlang registered Processes

-module(helloworld). 
-export([start/0]). 

start() ->
   io:fwrite("~p~n",[registered()]).

Erlang pid_to_list Processes

-module(helloworld). 
-export([start/0, call/2]). 

call(Arg1, Arg2) ->
   io:format("~p ~p~n", [Arg1, Arg2]). 

start() ->
   Pid = spawn(?MODULE, call, ["hello", "process"]), 
   io:fwrite("~p~n",[pid_to_list(Pid)]).

Erlang is_process_alive

-module(helloworld). 
-export([start/0, call/2]). 

call(Arg1, Arg2) ->
   io:format("~p ~p~n", [Arg1, Arg2]). 

start() -> 
   Pid = spawn(?MODULE, call, ["hello", "process"]), 
   io:fwrite("~p~n",[is_process_alive(Pid)]).

Erlang Processes is_pid

-module(helloworld). 
-export([start/0, call/2]). 

call(Arg1, Arg2) -> 
   io:format("~p ~p~n", [Arg1, Arg2]). 

start() -> 
   Pid = spawn(?MODULE, call, ["hello", "process"]), 
   io:fwrite("~p",[is_pid(Pid)]).

Erlang Processes

-module(helloworld). 
-export([start/0, call/2]). 

call(Arg1, Arg2) -> 
   io:format("~p ~p~n", [Arg1, Arg2]). 
start() -> 
   Pid = spawn(?MODULE, call, ["hello", "process"]), 
   io:fwrite("~p",[Pid]).

Erlang - Funs Functions within Functions

-module(helloworld). 
-export([start/0]). 

start() -> 
   Adder = fun(X) -> fun(Y) -> io:fwrite("~p~n",[X + Y]) end end, 
   A = Adder(6), 
   A(10).

Erlang Funs Using Variables

-module(helloworld). 
-export([start/0]). 

start() -> 
   B = 6, 
   A = fun(X) -> 
      io:fwrite("~p~n",[X]), 
      io:fwrite("~p~n",[B]) 
      end, 
   A(5).

Erlang Funs Example2

-module(helloworld). 
-export([start/0]). 

start() -> 
   A = fun(X) -> 
      io:fwrite("~p~n",[X]) 
      end, 
   A(5).

Erlang Funs

-module(helloworld). 
-export([start/0]). 

start() -> 
   A = fun() -> io:fwrite("Hello") end, 
   A().

Erlang Binaries binary_to_atom

-module(helloworld). 
-export([start/0]). 

start() -> 
   io:fwrite("~p~n",[binary_to_atom(<<"Erlang">>, latin1)]).

Previous 1 ... 5 6 7 8 9 10 11 ... 23 Next
Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.