"Richard O'Keefe" <[email protected]> writes:
> The problem we were asked about was specifically
> a
> aa
> aaa
> The code (iterate ('a':) "\n") does not give the right answer.
> It's not just that it produces an infinite list instead of three
> strings, it doesn't even start with the right string. It starts
> with "\n" when we need "a\n".
It was impossible to determine that from the question.
> To produce the specified output using that pattern, you need
> (take 3 . tail . iterate ('a':)) "\n"
take 9, surely?
> or any of several other alternatives.
>
> The original poster also didn't ask "what is the best way to do
> this", but specifically asked about doing it with list
> comprehension. Presumably this was an attempt to understand list
> comprehension better.
Perhaps, but as the OP didn't follow up to the message where
I said that it wasn't clear what the question was, by the
time Henning posted, I think he was justified in
generalising the question and taking the answer further.
This café is for discussion; it's not a suitable place for
asking a question, copying out the answer and disappearing
without further comment.
--
Jón Fairbairn [email protected]
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe