Anonymous user
Filter: Difference between revisions
correction, and results added.
Walterpachl (talk | contribs) m (→{{header|PL/I}}: semicolon) |
(correction, and results added.) |
||
Line 1,263:
=={{header|PL/I}}==
<lang PL/I>(subscriptrange):
declare a(20) fixed, b(*) fixed controlled;
declare (i, j, n) fixed binary;
a = random()*99999;
put list ('Unfiltered values:');
/* loop to count the number of elements that will be filtered */▼
put skip edit (a) (f(6));
n = 0;
do i = 1 to hbound(a);
Line 1,275 ⟶ 1,278:
allocate b(n);
j = 0;
do i = 1 to
if filter(a(i)) then do; j = j + 1; b(j) = a(i); end;
end;
put
put skip edit (b) (f(6));
filter: procedure (value) returns (bit(1));
Line 1,284 ⟶ 1,288:
return (iand(abs(value), 1) = 0);
end filter;
end filter_values;</lang>
Results:
<pre>
Unfiltered values:
44270 6008 80477 17004 91587 48669 29623 74640 29841 20019 77833 59865 49647 2272 54781
36154 40114 71893 25960 76863
Filtered values:
44270 6008 17004 74640 2272 36154 40114 25960
</pre>
=={{header|Pop11}}==
|