Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Share Thread:
Reddit Facebook Twitter
Tidy recursion
05-19-2013, 09:14 PM
Post: #3
RE: Tidy recursion
micheus
Thanks for the tips.
My doubts are due to Joe Armstrong saying this in Programming Erlang in a section about tail recursion:
Quote:if you write a function F that never returns (such as loop()), make sure that you never call anything after calling F, and don’t use F in a list or tuple constructor.
In both 1 and 2, the last expression looks like a list constructor, so it might inflate the stack noticeably if the binary is huge (I don't know for sure — no idea how these expressions would be compiled).
I think I picked up the trick with the arity bump and the introduction of an accumulator from the Wings source, so there must be a reason why this is used.
By contrast, the Haskell examples I've seen don't make a fuss about using the x:myFunction xs notation, and it really does look neat.

(05-18-2013 06:22 AM)micheus Wrote:  It's good see someone else coding for Wings3d. Smile
Well, what's the use. No one seems to be using my crap =)
Reply


Messages In This Thread
Tidy recursion - nemyax - 05-17-2013, 12:22 PM
RE: Tidy recursion - micheus - 05-18-2013, 06:22 AM
RE: Tidy recursion - nemyax - 05-19-2013 09:14 PM
RE: Tidy recursion - dgud - 05-20-2013, 01:50 PM
RE: Tidy recursion - micheus - 05-20-2013, 01:58 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)