Prelude.filter

This commit is contained in:
2021-08-12 18:49:36 -06:00
parent 821656b423
commit 595595ddc8
3 changed files with 10 additions and 2 deletions

View File

@@ -70,7 +70,7 @@ class Kiss {
"symbol" => Symbol("Prelude.symbol"),
"expList" => Symbol("Prelude.expList"),
"map" => Symbol("Lambda.map"),
"filter" => Symbol("Lambda.filter"), // TODO use truthy as the default filter function
"filter" => Symbol("Prelude.filter"),
"flatten" => Symbol("Lambda.flatten"),
"has" => Symbol("Lambda.has"),
"count" => Symbol("Lambda.count"),

View File

@@ -517,4 +517,10 @@ class Prelude {
throw "Can't run a subprocess on this target.";
#end
}
public static function filter<T>(l:Iterable<T>, ?p:(T) -> Bool):kiss.List<T> {
if (p == null)
p = Prelude.truthy;
return Lambda.filter(l, p);
}
}