Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Text-processing-2/Erlang/text-processing-2.erl
Normal file
31
Task/Text-processing-2/Erlang/text-processing-2.erl
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
-module( text_processing2 ).
|
||||
|
||||
-export( [task/0] ).
|
||||
|
||||
task() ->
|
||||
Name = "priv/readings.txt",
|
||||
try
|
||||
File_contents = text_processing:file_contents( Name ),
|
||||
[correct_field_format(X) || X<- File_contents],
|
||||
{_Previous, Duplicates} = lists:foldl( fun date_duplicates/2, {"", []}, File_contents ),
|
||||
io:fwrite( "Duplicates: ~p~n", [Duplicates] ),
|
||||
Good = [X || X <- File_contents, is_all_good_readings(X)],
|
||||
io:fwrite( "Good readings: ~p~n", [erlang:length(Good)] )
|
||||
|
||||
catch
|
||||
_:Error ->
|
||||
io:fwrite( "Error: Failed when checking ~s: ~p~n", [Name, Error] )
|
||||
end.
|
||||
|
||||
|
||||
|
||||
correct_field_format( {_Date, Value_flags} ) ->
|
||||
Corret_number = value_flag_records(),
|
||||
{correct_field_format, Corret_number} = {correct_field_format, erlang:length(Value_flags)}.
|
||||
|
||||
date_duplicates( {Date, _Value_flags}, {Date, Acc} ) -> {Date, [Date | Acc]};
|
||||
date_duplicates( {Date, _Value_flags}, {_Other, Acc} ) -> {Date, Acc}.
|
||||
|
||||
is_all_good_readings( {_Date, Value_flags} ) -> value_flag_records() =:= erlang:length( [ok || {_Value, ok} <- Value_flags] ).
|
||||
|
||||
value_flag_records() -> 24.
|
||||
Loading…
Add table
Add a link
Reference in a new issue