tag:blogger.com,1999:blog-4949964667779944881.post4000727874487491583..comments2024-03-28T09:11:54.298-07:00Comments on One Fork: Scala Permutations 2Rodhttp://www.blogger.com/profile/01080301889766047685noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-4949964667779944881.post-31985733148666217252011-04-09T09:55:56.048-07:002011-04-09T09:55:56.048-07:00All of these methods including Jesper's are re...All of these methods including Jesper's are recursive. This severely limits the size of the lists you want to permute otherwise you will get heap space issues. An iterative method would probably be a better idea.Joshua Hollanderhttps://www.blogger.com/profile/08730327067223241786noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-62540234895509088432011-03-02T13:26:54.691-08:002011-03-02T13:26:54.691-08:00Very cool! TY.Very cool! TY.Rodhttps://www.blogger.com/profile/01080301889766047685noreply@blogger.comtag:blogger.com,1999:blog-4949964667779944881.post-14443293980163365152011-03-02T04:17:08.305-08:002011-03-02T04:17:08.305-08:00This is better:
def perms[T](l : List[T]) : List[...This is better:<br /><br />def perms[T](l : List[T]) : List[List[T]] =<br /> if (l.isEmpty) List(l) else<br /> for (h <- l; t <- perms(l - h)) yield h :: tJesper Nordenberghttps://www.blogger.com/profile/07589508061874776093noreply@blogger.com