Example
In Haskell, the code example
filter evenevaluates to the list 2, 4,…10 by applying the predicate even
to every element of the list of integers 1, 2,… 10 in that order and creating a new list of those elements for which the predicate returns the boolean value true, thereby giving a list containing only the even members of that list. Conversely, the code example
evaluates to the list 1, 3,…9 by collecting those elements of the list of integers 1, 2… 10 for which the predicate even
returns the boolean value false (with .
being the function composition operator).
Read more about this topic: Filter (higher-order Function)
Famous quotes containing the word example:
“Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.”
—Marcel Proust (18711922)