
19 Mar
2009
19 Mar
'09
5:32 p.m.
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". To produce the specified output using that pattern, you need (take 3 . tail . iterate ('a':)) "\n" 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.