
On 7/20/11, Roelof Wobben
Hello,
I made this little script :
replicate :: Int -> a -> [a] replicate a xs = [xs | x' <= a <--xs]
I don't think this list comprehension works: - You've got the "<--" arrow instead of "<-". Maybe you're copy-pasting from Leksah, so it's causing the mistake in the copy-paste? - You haven't defined x' anywhere - I don't think you can combine a predicate (x' <= a) with a generator (a <- xs) - xs is your "feed" for the generator "a <- xs". What if, like in your example, xs is not a list? Also, for clarity, I would only name something "xs" if it is definitely a list. I don't want to spoon-feed you a solution, but I'd recommend: - Your "feed" in the generator (in your example the rightmost xs) being an infinite list, so that a is never a larger number than the number of elements in your "feed" - For clarity, don't define x', if you aren't going to use it. It's valid Haskell to write, for example: f :: [a] -> [Bool] f x = [True | _ <- x] Tom