The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

PedroPS (12) [Avatar] Offline

The "concat" function example provided in page 103 (boldface typing) is not "tail-recursive" (I think).
Doesn't it suffer from the same stack troubles as the before mentioned no-TR functions?
What's different in this case to be "acceptable"?

aslam.khan (50) [Avatar] Offline
Re: p 103. concat example
Hi Pedro

I'll look at that example again and get back to you. Stay tuned.
nresni (8) [Avatar] Offline
maybe ...

  def concat(ns: AList): AList = {
    def loop(xs: AList, acc: AList): AList = {
      if(xs.isEmpty) acc
      else loop(xs.tail, xs.head :: acc)
    loop(this, ns)