A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
23
Task/Filter/Sather/filter.sa
Normal file
23
Task/Filter/Sather/filter.sa
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
class MARRAY{T} < $ARR{T} is
|
||||
include ARRAY{T};
|
||||
|
||||
filter_by(r:ROUT{T}:BOOL):SAME is
|
||||
o:MARRAY{T} := #;
|
||||
loop e ::= elt!;
|
||||
if r.call(e) then
|
||||
o := o.append(#MARRAY{T}(|e|));
|
||||
end;
|
||||
end;
|
||||
return o;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
class MAIN is
|
||||
main is
|
||||
a ::= #MARRAY{INT}(|5, 6, 7, 8, 9, 10, 11|);
|
||||
sel ::= a.filter_by( bind(_.is_even) );
|
||||
loop #OUT + sel.elt! + " "; end;
|
||||
#OUT + "\n";
|
||||
end;
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue