! Copyright (C) 2012 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
-USING: combinators destructors fry io io.encodings.binary
-io.files io.streams.limited io.streams.random kernel locals
-math math.order random sequences sequences.private ;
+USING: fry io kernel locals math random sequences
+sequences.private ;
IN: io.random
r n < [ line r accum set-nth-unsafe ] when
] if
] each-numbered-line accum ;
-
-: random-file ( n path -- )
- [
- [ <random-stream> swap limit-stream ]
- [ binary <file-writer> ] bi*
- [ &dispose ] bi@ stream-copy
- ] with-destructors ;
! Copyright (C) 2010 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: destructors io kernel random sequences ;
+USING: destructors io io.encodings.binary io.files
+io.streams.limited kernel random sequences ;
IN: io.streams.random
TUPLE: random-stream ;
M: random-stream dispose drop ;
INSTANCE: random-stream input-stream
+
+: random-file ( n path -- )
+ [
+ [ <random-stream> swap limit-stream ]
+ [ binary <file-writer> ] bi*
+ [ &dispose ] bi@ stream-copy
+ ] with-destructors ;