Skip to content

Commit

Permalink
little refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
eshubin committed Apr 16, 2013
1 parent e4bcecb commit 0e08bf1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/interval_reader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@

read(FileName) ->
{ok, Bin} = file:read_file(FileName),
%% {ok, IO} = file:open(FileName, [read]),
D = orddict:new(),
read(binary_to_list(Bin), D).


read(IO, Acc) ->
case parse(IO) of
read(Str, Acc) ->
case parse(Str) of
{{Left, Right}, Float, Rest} ->
read(Rest, orddict:store(Right, {Left, Float}, Acc));
_ ->
eof ->
Acc
end.

parse(IO) ->
case io_lib:fread(?PARSE_FORMAT, IO) of
parse(Str) ->
case io_lib:fread(?PARSE_FORMAT, Str) of
{ok, [Left, Right, Float], Rest} when (Left =< Right) ->
{{Left, Right}, Float, Rest};
{more, ?PARSE_FORMAT, 0, _} ->
Expand Down

0 comments on commit 0e08bf1

Please sign in to comment.