Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
-module(cc).
|
||||
|
||||
-export([start/0]).
|
||||
|
||||
start() ->
|
||||
My_pid = erlang:self(),
|
||||
Pid = erlang:spawn( fun() -> reader(My_pid, 0) end ),
|
||||
{ok, IO } = file:open( "input.txt", [read] ),
|
||||
process( io:get_line(IO, ""), IO, Pid ),
|
||||
file:close( IO ).
|
||||
|
||||
process( eof, _IO, Pid ) ->
|
||||
Pid ! count,
|
||||
receive
|
||||
I -> io:fwrite("Count:~p~n", [I])
|
||||
end;
|
||||
process( Any, IO, Pid ) ->
|
||||
Pid ! Any,
|
||||
process( io:get_line(IO, ""), IO, Pid ).
|
||||
|
||||
reader(Pid, C) ->
|
||||
receive
|
||||
count -> Pid ! C;
|
||||
Any ->
|
||||
io:fwrite("~s", [Any]),
|
||||
reader(Pid, C+1)
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue