When I try to use the function below to implement a function like below the compiler return
parse error (possibly incorrect indentation or mismatched brackets)
The function:
demo 8 [1,2,3] should return [1,2,3,1,2,3,1,2]
demo :: Int -> [a] -> [a]
let n = 0
demo arg [] = []
demo arg (x:xs) =
if arg <= length (x:xs) then
take arg (x:xs)
else
let (x:xs) = (x:xs) ++ (x:xs)!!n
arg = arg - 1
n = n + 1
demo arg (x:xs)
How can I correct that? Regards!