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

More like LOLiver amirite

% hello world program
-module(helloworld).
-export([start/0]).
-export([recv/0]).
-export([sender/3]).

start() ->
    Printer = 'spawn'(?MODULE, recv, []),
    Sender = 'spawn'(?MODULE, sender, [Printer, 5, "asdf"]),
    timer:sleep(300),
    Sender ! { 'NewMessage', "hjkl" }
    .

sender(Printer, Num, Message) ->
    receive
        { 'NewMessage', NM } ->
            sender(Printer, Num, NM)
    after
        100 ->
            if
                Num > 0 -> 
                    Printer ! Message,
                    timer:sleep(100),
                    sender(Printer, Num - 1, Message);
                true -> 'Done'
            end
    end.   

recv() ->
    receive
        Message -> 
            io:fwrite("Message: ~s\n", [Message]),
            recv()
    end.

Advertisements
Loading...

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