title: Stream iterate can someone provide a walkthrough of this example code
body: <p>So for splitting a number into its digits I found this code</p>
  
  <pre><code>    def split(n: Int) = if (n == 0) List(0) else { 
      (Stream.iterate(n)(_/10)takeWhile(_!=0)map(_%10)toList) reverse
  }
  </code></pre>
  
  <p><a href="http://www.scala-lang.org/old/node/11647.html" rel="nofollow">code</a></p>
  
  <p>which works but I couldn't explain to myself how the computation flows . Could anyone provide more insight into the intermediate steps it takes to go from</p>
  
  <pre><code>split(123) 
  List[Int] = List(3,2,1)
  </code></pre>
  
  <p>It seems fairly straightforward but reading the method declarations and trying to work examples with calculator I failed to re-create myself the result.</p>