Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(files).
- -export([readlines/1]).
- readlines(Filename) ->
- {ok, Data} = file:read_file(Filename),
- RevLines = lines(Data, []),
- lists:reverse(RevLines).
- lines(Input, Lines) ->
- case erlang:decode_packet(line, Input, []) of
- {ok, Line, Rest} ->
- lines(Rest, [Line|Lines]);
- {more, _} ->
- [Input|Lines]
- end.
Add Comment
Please, Sign In to add comment