tag:blogger.com,1999:blog-3459037735648203218.post7058207947168316068..comments2018-11-12T22:49:16.515+00:00Comments on F# Code: SplitEvery (chunk)holoedhttp://www.blogger.com/profile/06023475066034907250noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-3459037735648203218.post-77526207282508213152010-06-27T03:02:42.896+01:002010-06-27T03:02:42.896+01:00“If you know how to cheat, start now.” ;) (quoting...“If you know how to cheat, start now.” ;) (quoting a famous Baltimore's baseball player)Stringernoreply@blogger.comtag:blogger.com,1999:blog-3459037735648203218.post-2026308779745780022010-06-26T16:33:11.435+01:002010-06-26T16:33:11.435+01:00But it's cheating if you use mutable types. :...But it's cheating if you use mutable types. :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3459037735648203218.post-81014482750145962792010-06-26T13:51:36.923+01:002010-06-26T13:51:36.923+01:00I have written a more efficient solution, yet stil...I have written a more efficient solution, yet still readable:<br />http://gist.github.com/453478Stringernoreply@blogger.comtag:blogger.com,1999:blog-3459037735648203218.post-59766690053452035592010-06-25T09:39:40.961+01:002010-06-25T09:39:40.961+01:00I have written almost same code too, see my functi...I have written almost same code too, see my function cut:<br />http://stackoverflow.com/questions/2649161/need-help-regarding-async-and-fsi<br />But your function slipEvery do not terminate, I think you should add a test like:<br />if (vs.Count() <> 0) then yield! splitEvery n vsStringerhttps://www.blogger.com/profile/12254565346526143350noreply@blogger.comtag:blogger.com,1999:blog-3459037735648203218.post-9804834177344602842010-03-12T21:17:11.412+00:002010-03-12T21:17:11.412+00:00I agree with you. I like the simplicity of it thou...I agree with you. I like the simplicity of it thought. I will provide a more efficient SplitAt (as soon as I get the time), one that doesn't enumerate twice. Thank you for your comment.holoedhttps://www.blogger.com/profile/06023475066034907250noreply@blogger.comtag:blogger.com,1999:blog-3459037735648203218.post-60474184837688168652010-03-12T18:19:41.293+00:002010-03-12T18:19:41.293+00:00This seems rather inefficient, since you are enume...This seems rather inefficient, since you are enumerating over the enumerable twice for every split. The further you get into the enumerable the worse things are (imagine a 10000 element enumerable split every 10, on the 1000th split you are skipping 9990 elements to get the last 10).<br /><br />This is the version I use (which, itself, could probably stand some improvement): http://gist.github.com/330586Joe W.https://www.blogger.com/profile/16894632241919894237noreply@blogger.com