Talk:One of n lines in a file: Difference between revisions

Line 6:
I believe that this task implicitly assumes that a single line will always be small enough to be kept in memory? If so, I think that this assumption should be explicitly stated. (It sounds silly, but it can turn into a real issue.) --[[User:Rdm|Rdm]] 20:19, 14 September 2011 (UTC)
: Choosing a random item from a sequence of unknown length has its uses other than reading files. Actually since the task doesn't ask anyone to read a file anyway, shouldn't it be named something else like, er, "Choosing a random item from a sequence of unknown length"? --[[User:Ledrug|Ledrug]] 20:36, 14 September 2011 (UTC)
:: Ok... well... I implemented it so that if the file is under 10 MB, the entire sequence is handled at once. In most practical situations this means that the length is not unknown. If this were a serious exercise I would increase the buffer size to 100MB. --[[User:Rdm|Rdm]] 11:10, 15 September 2011 (UTC)
 
I don't know whether it's worth noting or not, but there will be issues relating to precision in implementations' real, non-integer numeric types and with precision in its random number generator. --[[User:Short Circuit|Michael Mol]] 21:18, 14 September 2011 (UTC)
6,951

edits