]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix deploy size regresson
authorU-SLAVA-DFB8FF805\Slava <Slava@slava-dfb8ff805.(none)>
Mon, 6 Oct 2008 03:08:13 +0000 (22:08 -0500)
committerU-SLAVA-DFB8FF805\Slava <Slava@slava-dfb8ff805.(none)>
Mon, 6 Oct 2008 03:08:13 +0000 (22:08 -0500)
basis/random/random-docs.factor [changed mode: 0644->0755]
basis/random/random.factor [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 51656a7..18c9ca7
@@ -15,21 +15,18 @@ HELP: random-bytes*
 { $description "Generates a byte-array of random bytes." } ;
 
 HELP: random
-{ $values { "obj" object } { "elt" "a random element" } }
-{ $description "Outputs a random element of the input object. If the object is an integer, an input of zero always returns a zero, while any other integer integers yield a random integer in the interval between itself and zero, inclusive of zero. On a sequence, an empty sequence always outputs " { $link f } "." }
+{ $values { "seq" sequence } { "elt" "a random element" } }
+{ $description "Outputs a random element of the input sequence. Outputs " { $link f } " if the sequence is empty." }
+{ $notes "Since integers are sequences, passing an integer " { $snippet "n" } " outputs an integer in the interval " { $snippet "[0,n)" } "." }
 { $examples
     { $unchecked-example "USING: random prettyprint ;"
         "10 random ."
         "3" }
-    { $example "USING: random prettyprint ;"
-        "0 random ."
-        "0" }
     { $unchecked-example "USING: random prettyprint ;"
-        "-10 random ."
-        "-8" }
-    { $unchecked-example "USING: random prettyprint ;"
-        "{ \"a\" \"b\" \"c\" } random ."
-        "\"a\"" }
+        "SYMBOL: heads"
+        "SYMBOL: tails"
+        "{ heads tails } random ."
+        "heads" }
 } ;
 
 HELP: random-bytes
@@ -74,7 +71,10 @@ ARTICLE: "random-protocol" "Random protocol"
 { $subsection seed-random } ;
 
 ARTICLE: "random" "Generating random integers"
-"The " { $vocab-link "random" } " vocabulary contains a protocol for generating random or pseudorandom numbers. The ``Mersenne Twister'' pseudorandom number generator algorithm is the default generator stored in " { $link random-generator } "."
+"The " { $vocab-link "random" } " vocabulary contains a protocol for generating random or pseudorandom numbers."
+$nl
+"The ``Mersenne Twister'' pseudorandom number generator algorithm is the default generator stored in " { $link random-generator } "."
+$nl
 "Generate a random object:"
 { $subsection random }
 "Combinators to change the random number generator:"
old mode 100644 (file)
new mode 100755 (executable)
index b5f8ac4..845f8e0
@@ -33,10 +33,6 @@ M: f random-32* ( obj -- * ) no-random-number-generator ;
         random-generator get random-bytes*
     ] keep head ;
 
-GENERIC: random ( obj -- elt )
-
-: random-bits ( n -- r ) 2^ random ;
-
 <PRIVATE
 
 : random-integer ( n -- n' )
@@ -46,18 +42,13 @@ GENERIC: random ( obj -- elt )
 
 PRIVATE>
 
-M: sequence random ( seq -- elt )
+: random-bits ( n -- r ) 2^ random-integer ;
+
+: random ( seq -- elt )
     [ f ] [
         [ length random-integer ] keep nth
     ] if-empty ;
 
-M: integer random ( integer -- integer' )
-    dup sgn {
-        {  0 [ ] }
-        { -1 [ neg random-integer neg ] }
-        {  1 [ random-integer ] }
-    } case ;
-
 : delete-random ( seq -- elt )
     [ length random-integer ] keep [ nth ] 2keep delete-nth ;