io.streams.random: adding @erg's random-stream.

db4
John Benediktsson 2012-10-25 21:37:58 -07:00
parent 23fc7b3eb9
commit 916d912492
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1 @@
Doug Coleman

View File

@ -0,0 +1,21 @@
! Copyright (C) 2010 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: destructors io kernel random sequences ;
IN: io.streams.random
TUPLE: random-stream ;
C: <random-stream> random-stream
M: random-stream stream-element-type drop +byte+ ;
M: random-stream stream-read-unsafe
drop [ dup random-bytes ] [ 0 swap copy ] bi* ;
M: random-stream stream-read1 drop 256 random ;
M: random-stream stream-read-partial-unsafe stream-read-unsafe ;
M: random-stream dispose drop ;
INSTANCE: random-stream input-stream