Scala recursion no side effects -


ok, recursion more functional because not changing state of object in iteration. there nothing stopping in scala.

  var magoo = 7;     def mergesort(xs: list[int]): list[int] = {     ...     magoo = magoo + 1     mergesort(xs1, xs2);    } 

in fact, can make recursion side effectless in scala can in java. fair scala make easier write concise recursion using pattern matching? there nothing stopping me writing stateless recursion code in java can write in scala?

the point in scala complex recursion can achieved neater code. that's all. correct?

if course can complex recursion in java. complex recursion in assembler if wanted to. in scala easier do. scala has tail call optimisation important if want write arbitrary iterative algorithm recursive method without getting stack overflow or performance drop.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -