tag:blogger.com,1999:blog-8965734277283465944.post7859496622029983673..comments2024-02-21T21:28:36.078-08:00Comments on Dublin Tech: How could Scala do a merge sort?Alex Staveleyhttp://www.blogger.com/profile/04378245339254378938noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-8965734277283465944.post-53404570301695651292013-06-01T18:12:29.261-07:002013-06-01T18:12:29.261-07:00@Eric Springer: https://gist.github.com/ramn/56922...@Eric Springer: https://gist.github.com/ramn/5692237 slightly modified, I put lists back into it for nicer pattern matching. This runs in around 280 ms for me. The version you have takes minutes! Be sure to prepend to lists, not append since prepend is a constant time operation.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8965734277283465944.post-17865612577655381602013-05-19T11:43:42.457-07:002013-05-19T11:43:42.457-07:00@Pointy -- No, you can very easily make merge tail...@Pointy -- No, you can very easily make merge tail recursive. You just add an extra argument, which is strict in scala, and build it there. There's an example in my post:<br /><br />http://ericwspringer.blogspot.com/2013/05/sorry-but-no-even-merge-sort-sucks-in.html<br /><br />but you can just as easily do it with cons'ingAnonymoushttps://www.blogger.com/profile/03116296053498755356noreply@blogger.comtag:blogger.com,1999:blog-8965734277283465944.post-55777558243860443882013-05-19T07:16:40.297-07:002013-05-19T07:16:40.297-07:00Not only that, but the "merge" step can&...Not only that, but the "merge" step can't employ tail recursion. I really don't think this is the right way to approach the problem.Pointyhttps://www.blogger.com/profile/15300865803415441792noreply@blogger.comtag:blogger.com,1999:blog-8965734277283465944.post-52355631212285522072013-05-19T04:13:29.347-07:002013-05-19T04:13:29.347-07:00But Scala approach is much slower, cause there is ...But Scala approach is much slower, cause there is a need to produce a lot of intermediate objects, while Java's version use only one auxilary array.funny_falconhttps://www.blogger.com/profile/07247716942015581766noreply@blogger.comtag:blogger.com,1999:blog-8965734277283465944.post-22006258277758256282013-05-18T22:27:51.907-07:002013-05-18T22:27:51.907-07:00Great post Alex. Looking forward to See more of th...Great post Alex. Looking forward to See more of this type. Though I am not a great Scala fan, but I like to take what best Scala offers. <br /><br />Javin<br /><a href="http://javarevisited.blogspot.com.br/" rel="nofollow">http://javarevisited.blogspot.com/</a>javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.com