Profile

Array.filter

Array.filter

NAME

Array::filter - Filter a list according to a predicate.

SYNOPSIS

[a] filter( Bool(a) p, [a] xs )

ARGUMENTS

p The predicate to test against

xs The array to filter

DESCRIPTION

Each element of xs is tested against the predicate p

The returned list contains those elements of xs for which the predicate is true. The predicate function may of course be partially applied for ease of programming.


 Bool isDiv(Int d,Int a) {
     return (a%d==0);
 }
 
 Void main() {
     ints = [1,2,3,4,5,6,7,8];
     odds = filter(isDiv@(3),ints);
     // odds = [3,6];
 }

Naturally, all(p,filter(p,xs)) == any(p,xs)

AUTHORS

Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/

LICENSE

The Kaya standard library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (version 2.1 or any later version) as published by the Free Software Foundation.

RELATED

Array.any(3kaya)

Array.all(3kaya)

Latest Tech News
Your Notes

Sign in/Sign up

Signing in to our system allows you to post your contributions and vote on the contributions of others. It will also allow you to get extra perts like having your favorites in the cloud and having your persistent personal notes wherever you go. More will be added as we scale up our services.

By signing in to our system, you agree our Member Terms and Conditions


Sign-in with one of the following services

Almost finished!

Please select a screen name for NET SOUP.



 Please send me news and special offers from NET SOUP.

 I have read and accept the Terms of Use.

COMPLIMENTARY EXAMPLES

We have no example yet for this entry


Your Name
Now

Community Contributions and Discussions

Modify your search

View Documentation

Jobs from Indeed