io.streams.random: moving random-file here.
parent
032458e5d7
commit
cff606f474
|
@ -1,9 +1,8 @@
|
||||||
! Copyright (C) 2012 John Benediktsson
|
! Copyright (C) 2012 John Benediktsson
|
||||||
! See http://factorcode.org/license.txt for BSD license
|
! See http://factorcode.org/license.txt for BSD license
|
||||||
|
|
||||||
USING: combinators destructors fry io io.encodings.binary
|
USING: fry io kernel locals math random sequences
|
||||||
io.files io.streams.limited io.streams.random kernel locals
|
sequences.private ;
|
||||||
math math.order random sequences sequences.private ;
|
|
||||||
|
|
||||||
IN: io.random
|
IN: io.random
|
||||||
|
|
||||||
|
@ -27,10 +26,3 @@ PRIVATE>
|
||||||
r n < [ line r accum set-nth-unsafe ] when
|
r n < [ line r accum set-nth-unsafe ] when
|
||||||
] if
|
] if
|
||||||
] each-numbered-line accum ;
|
] each-numbered-line accum ;
|
||||||
|
|
||||||
: random-file ( n path -- )
|
|
||||||
[
|
|
||||||
[ <random-stream> swap limit-stream ]
|
|
||||||
[ binary <file-writer> ] bi*
|
|
||||||
[ &dispose ] bi@ stream-copy
|
|
||||||
] with-destructors ;
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
! Copyright (C) 2010 Doug Coleman.
|
! Copyright (C) 2010 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! 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
|
IN: io.streams.random
|
||||||
|
|
||||||
TUPLE: random-stream ;
|
TUPLE: random-stream ;
|
||||||
|
@ -19,3 +20,10 @@ M: random-stream stream-read-partial-unsafe stream-read-unsafe ;
|
||||||
M: random-stream dispose drop ;
|
M: random-stream dispose drop ;
|
||||||
|
|
||||||
INSTANCE: random-stream input-stream
|
INSTANCE: random-stream input-stream
|
||||||
|
|
||||||
|
: random-file ( n path -- )
|
||||||
|
[
|
||||||
|
[ <random-stream> swap limit-stream ]
|
||||||
|
[ binary <file-writer> ] bi*
|
||||||
|
[ &dispose ] bi@ stream-copy
|
||||||
|
] with-destructors ;
|
||||||
|
|
Loading…
Reference in New Issue