.\" This man page is automatically generated using .\" kayadoc2man from the Kaya development tools and the -xmldocs compile .\" option. Editing it directly is not encouraged. .\" It is under the same license as the source .k file that it was .\" generated from. .TH "Array.filter" "3kaya" "August 2014" "Kaya" "Kaya module reference" .SH "NAME" Array::filter \- Filter a list according to a predicate. .SH "SYNOPSIS" .B [a] filter( \fIBool(a) p, [a] xs\fP .B ")" .SH "ARGUMENTS" .PP .B "p" The predicate to test against .PP .B "xs" The array to filter .SH "DESCRIPTION" .PP Each element of \fIxs\fP is tested against the predicate \fIp\fP The returned list contains those elements of \fIxs\fP for which the predicate is true. The predicate function may of course be partially applied for ease of programming. .IP "" -4 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]; } .PP Naturally, \fBall(p,filter(p,xs)) == any(p,xs) \fP .SH "AUTHORS" Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/ .SH 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. .SH "RELATED" .PD 0 .PP .B "Array.any"(3kaya) .PP .B "Array.all"(3kaya) .PD 0.4v