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: | take |
Type: | Int -> [a] -> [a] |
Description: | creates a list, the first argument determines, how many items should be taken from the list passed as the second argument |
Related: | cycle, iterate, repeat, replicate |
Input: take 5 [1,2,3,4,5,6,7]
Output: [1,2,3,4,5]
Input: take 5 [1,2]
Output: [1,2]
Input: take 0 [1,2,3,4,5,6,7]
Output: []
Input: take 5 (repeat 3)
Output: [3,3,3,3,3]
Input: take 10 (iterate (2*) 1)
Output: [1,2,4,8,16,32,64,128,256,512]
Input: take 10 (cycle [1,2,3])
Output: [1,2,3,1,2,3,1,2,3,1]