Implementing Haskell's `take` function using `foldl`
Implementing Haskell's take and drop functions using foldl . Any suggestions on how to implement take and drop functions using foldl ?? take x ls = foldl ??? drop x ls = foldl ??? i've tried these but it's showing errors: myFunc :: Int -> [a] -> [a] myFunc n list = foldl func [] list where func x y | (length y) > n = x : y | otherwise = y ERROR PRODUCED : *** Expression : foldl func [] list *** Term : func *** Type : a -> [a] -> [a] *** Does not match : [a] -> [a] -> [a] *** Because : unification would give infinite type Can't be done. Left fold necessarily diverges on infinite lists, but take