4

Looking at how repeat definition is see:

repeat x = xs where xs = x : xs

What's the reason for having the local xs definition here, instead of just defining

repeat x = x : repeat x

I suspect it has something to do with compiler optimizations enabled due to better inlining, but I'm really just guessing. Does anybody know the actual reason(s)?

Frerich Raabe
  • 90,689
  • 19
  • 115
  • 207

0 Answers0