Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Beginner question

49 views
Skip to first unread message

Abhinav Gogna

unread,
Dec 19, 2014, 9:36:22 PM12/19/14
to
Hello Geniuses!

I am beginner in haskell and going through learn you a haskell.

In recursion chapter, there is an implementation of take function. I am trying to implement it another way but keep getting compiler error "Not in scope: 'as'"

Here is the code:

take' :: Int -> [a] -> [a]
take' _ [] = []
take' x _
| x _ <= 0 = []
| otherwise x (a:as) = a : take' (x-1) as

Can someone tell me what is wrong with this program?

Abhinav Gogna

unread,
Dec 20, 2014, 2:15:11 PM12/20/14
to
I figured it out. I had to pass it before the guards.
Here is the code:

take'' :: Int -> [a] -> [a]
take'' _ [] = []
take'' x (a:as)
| x <= 0 = []
| otherwise = take' (x-1) as
0 new messages