tag:blogger.com,1999:blog-2012573949883447809.post2608266554810592218..comments2024-02-06T11:01:09.832+01:00Comments on void-main-args: Folding Stream with Scalavoidmainargshttp://www.blogger.com/profile/00911109433888554531noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-2012573949883447809.post-30195007975357648252013-01-30T21:51:24.968+01:002013-01-30T21:51:24.968+01:00walter: I don't think there's any good rea...walter: I don't think there's any good reason for that. What would be better would be:<br /><br />def foldr[A, B](xs: Stream[A], base: B)( combine: (A, =>B) => B): B<br /><br />This allows Scala type inference to figure out what A is from the value of xs, and what B is from the value of base, so that you don't need to specify those types when writing combine. But that requires currying: to infer type parameters, Scala takes the types of all arguments in a parameter list; the results of type inference can be used then only in *next* parameter list.<br />This way, you could just write all the function arguments of foldr as anonymous functions, without any type declaration for them.Anonymoushttps://www.blogger.com/profile/04485097839438234853noreply@blogger.comtag:blogger.com,1999:blog-2012573949883447809.post-45876112030803772702012-04-05T06:28:56.544+02:002012-04-05T06:28:56.544+02:00what is the reason of currying stream here:
def f...what is the reason of currying stream here:<br /><br />def foldr[A, B]( combine: (A, =>B) => B, base: B )(xs: Stream[A]): B ...<br /><br />vs.<br /><br />def foldr[A, B]( combine: (A, =>B) => B, base: B, xs: Stream[A]): B<br /><br />Thank you,<br />walterwalternoreply@blogger.comtag:blogger.com,1999:blog-2012573949883447809.post-34301141622912431002011-10-24T19:55:58.335+02:002011-10-24T19:55:58.335+02:00@oxbow thanks for the information. The blog is upd...@oxbow thanks for the information. The blog is updated accordingly.voidmainargshttps://www.blogger.com/profile/00911109433888554531noreply@blogger.comtag:blogger.com,1999:blog-2012573949883447809.post-30855703414527161012011-10-20T13:51:58.859+02:002011-10-20T13:51:58.859+02:00scala does have Haskell's "break" - ...scala does have Haskell's "break" - it is called "span"oxbowhttps://www.blogger.com/profile/09110490196361200081noreply@blogger.com