take n [...]

Takes the first n items from the list.

Example

Lazy Evaluation Example

> ones = 1 : ones
> tenOnes = take 10 ones
[1,1,1,1,1,1,1,1,1,1]

Formal Implementation

take _ [] = []
take 0 _ = []
take n (x:xs) = x : take (n-1) xs