Text processing/2: Difference between revisions
Content added Content deleted
(removed omit from phix) |
|||
Line 101: | Line 101: | ||
=={{header|Aime}}== |
=={{header|Aime}}== |
||
<lang aime> |
<lang aime>check_format(list l) |
||
check_format(list l) |
|||
{ |
{ |
||
integer i; |
integer i; |
||
Line 108: | Line 107: | ||
if (~l != 49) { |
if (~l != 49) { |
||
error(" |
error("bad field count"); |
||
} |
} |
||
s = l[0]; |
s = l[0]; |
||
if ( |
if (match("????-??-??", s)) { |
||
error("bad date format"); |
error("bad date format"); |
||
} |
} |
||
l[0] = |
l[0] = s.delete(7).delete(4).atoi; |
||
i = 1; |
i = 1; |
||
while (i < 49) { |
while (i < 49) { |
||
atof(l[i]); |
|||
i += 1; |
i += 1; |
||
l[i] = atoi(l[i]); |
l[i >> 1] = atoi(l[i]); |
||
i += 1; |
i += 1; |
||
} |
} |
||
l.erase(25, -1); |
|||
} |
} |
||
integer |
|||
main(void) |
main(void) |
||
{ |
{ |
||
Line 140: | Line 140: | ||
while (f.list(l, 0) != -1) { |
while (f.list(l, 0) != -1) { |
||
if (!trap(check_format, l)) { |
if (!trap(check_format, l)) { |
||
if ( |
if ((x[v = lf_x_integer(l)] += 1) != 1) { |
||
v_form("duplicate ~ line\n", v); |
v_form("duplicate ~ line\n", v); |
||
} |
} |
||
x[v] = 0; |
|||
i = 1; |
i = 1; |
||
l.ucall(min_i, 1, i); |
|||
goods += iclip(0, i, 1); |
|||
break; |
|||
} |
|||
i += 2; |
|||
} |
|||
if (48 < i) { |
|||
goods += 1; |
|||
} |
|||
} |
} |
||
} |
} |
||
Line 160: | Line 152: | ||
o_(goods, " good lines\n"); |
o_(goods, " good lines\n"); |
||
0; |
|||
}</lang> |
}</lang> |
||
{{out}} (the "reading.txt" needs to be converted to UNIX end-of-line) |
{{out}} (the "reading.txt" needs to be converted to UNIX end-of-line) |