Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module (numcount).
- -export ([load/1,count/3,compare/1]).
- %modification of charcount example
- load(F)->
- {ok, List} = file:read_file(F),
- L=binary_to_list(List),
- io:fwrite("Result\n"),
- Result=compare(L),
- Result.
- count(Ch, [],N)->N;
- count(Ch, [H|T],N) ->
- case Ch==H of
- true-> count(Ch,T,N+1);
- false -> count(Ch,T,N)
- end.
- compare(L)->
- Alph=[$0,$1,$2,$3,$4,$5,$6,$7,$8,$9],
- rgo(Alph,L,[]).
- rgo([H|T],L,Result)->
- N=count(H,L,0),
- Result2=Result++[{[H],N}],
- rgo(T,L,Result2);
- rgo([],L,Result)->Result.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement