Rechercher une page de manuel
Array.filter.3kaya
Langue: en
Version: May 2010 (fedora - 01/12/10)
Section: 3 (Bibliothèques de fonctions)
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];
}
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)
Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre