ZVON > References > Haskell reference |
Intro / Search / ZVON |
| Indexes | Syntax | >> Prelude << | Ratio | Complex | Numeric | Ix | Array | List | Maybe | Char | Monad | IO | Directory | System | Time | Locale | CPUTime | Random |
Module: | Prelude |
---|---|
Function: | takeWhile |
Type: | (a -> Bool) -> [a] -> [a] |
Description: | creates a list from another one, it inspects the original list and takes from it its elements to the moment when the condition fails, then it stops processing |
Related: |
Input: takeWhile (<3) [1,2,3,4,5]
Output: [1,2]
Input: takeWhile (>3) [1,2,3,4,5]
Output: []
Input: takeWhile odd [1,3,5,7,9,10,11,13,15,17]
Output: [1,3,5,7,9]
Input: takeWhile (\x -> 6*x < 100) [1..20]
Output: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Input: takeWhile ('w'>) "hello world"
Output: "hello "