[Haskell] recursion patterns?
7stud
7stud at excite.com
Wed May 15 21:16:56 CEST 2013
>> Is one solution more efficient than the other? I believe my solution is
>> tail recursive, but it's my understanding that compilers can now
>> optimize just about anything into tail recursion.
>The first solution works for infinite lists and the second one does not.
I don't see how that's possible. Both traversals seem to be limited by n, and therefore they do not have to touch the end of the list. In any case, it would seem to me that the *first* solution would be the one that wouldn't work on an infinite list. Can you explain?
>It's really like foldr vs. foldl.
Hmm...I never thought of foldr and foldl in those terms. Thanks.
I'l be sure to post any other questions I have on the beginner list.
More information about the Haskell
mailing list