Paste: first shot at random.org fun
Author: | _hrrld |
Mode: | factor |
Date: | Thu, 6 Nov 2008 02:11:16 |
Plain Text |
USING: http.client kernel sequences splitting accessors make math.parser combinators ;
IN: randomdotorg
TUPLE: randomdotorg num min max base ;
C: <randomdotorg> randomdotorg
GENERIC: get ( randomdotorg -- {num} )
: (get-clean) ( nums http-response -- {num} )
[ 10 = ] trim-right "\n" split swap drop ;
M: randomdotorg get ( randomdotorg -- {num} )
{ [ base>> ] [ max>> ] [ min>> ] [ num>> ] } cleave
[ "http://www.random.org/integers/?num=" , number>string ,
"&min=" , number>string ,
"&max=" , number>string ,
"&col=1&base=" , number>string ,
"&format=plain&rnd=new" ,
] { } make "" swap [ append ] each http-get (get-clean) ;
New Annotation