Text processing/2: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: syntax coloured, made p2js compatible) |
|||
Line 2,155: | Line 2,155: | ||
1993-03-28 at Line : 1184 |
1993-03-28 at Line : 1184 |
||
1995-03-26 at Line : 1911</pre> |
1995-03-26 at Line : 1911</pre> |
||
=={{header|Picat}}== |
|||
<lang Picat>import util. |
|||
go => |
|||
Readings = [split(Record) : Record in read_file_lines("readings.txt")], |
|||
DateStamps = new_map(), |
|||
GoodReadings = 0, |
|||
foreach({Rec,Id} in zip(Readings,1..Readings.length)) |
|||
if Rec.length != 49 then printf("Entry %d has bad_length %d\n", Id, Rec.length) end, |
|||
Date = Rec[1], |
|||
if DateStamps.has_key(Date) then |
|||
printf("Entry %d (date %w) is a duplicate of entry %w\n", Id, Date, DateStamps.get(Date)) |
|||
else |
|||
if sum([1: I in 3..2..49, check_field(Rec[I])]) == 0 then |
|||
GoodReadings := GoodReadings + 1 |
|||
end |
|||
end, |
|||
DateStamps.put(Date, Id) |
|||
end, |
|||
nl, |
|||
printf("Total readings: %d\n",Readings.len), |
|||
printf("Good readings: %d\n",GoodReadings), |
|||
nl. |
|||
check_field(Field) => |
|||
Field == "-2" ; Field == "-1" ; Field == "0".</lang> |
|||
{{out}} |
|||
<pre>Entry 85 (date 1990-03-25) is a duplicate of entry 84 |
|||
Entry 456 (date 1991-03-31) is a duplicate of entry 455 |
|||
Entry 820 (date 1992-03-29) is a duplicate of entry 819 |
|||
Entry 1184 (date 1993-03-28) is a duplicate of entry 1183 |
|||
Entry 1911 (date 1995-03-26) is a duplicate of entry 1910 |
|||
Total readings: 5471 |
|||
Good readings: 5013</pre> |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |