retroforth/source/interfaces/io/rng.retro
crc 2ff677c5d3 proper rng device in retro-unix
FossilOrigin-Name: fc95ae344b6ea961c9e65426b0b8820104c4b9f9a74a35a125635f207fff2b16
2019-10-14 15:17:43 +00:00

20 lines
317 B
Text

## Random Value
~~~
{{
'io var
:identify
@io n:zero? [
#10 io:scan-for dup n:negative?
[ drop 'IO_DEVICE_TYPE_0010_NOT_FOUND s:put nl ]
[ !io ] choose ] if ;
---reveal---
:io:rng identify @io io:invoke ;
}}
~~~
Return a random value from /dev/urandom
~~~
:n:random (-n) io:rng ;
~~~