]> gitweb.factorcode.org Git - factor.git/commitdiff
made another file
authorDoug Coleman <erg@trifocus.net>
Sat, 21 Jan 2006 06:23:41 +0000 (06:23 +0000)
committerDoug Coleman <erg@trifocus.net>
Sat, 21 Jan 2006 06:23:41 +0000 (06:23 +0000)
contrib/random-tester/load.factor
contrib/random-tester/random-tester.factor
contrib/random-tester/random.factor [new file with mode: 0644]

index e9ad75b077f86d8606586c771ed7045f215beb43..06583c7cb6392e6bbb079577a9fcbb32c6af85a5 100644 (file)
@@ -3,5 +3,6 @@ IN: scratchpad
 
 {
     "utils"
+    "random"
     "random-tester"
 } [ "/contrib/random-tester/" swap ".factor" append3 run-resource ] each
index a0b8234a02ce6c5c14b505e23b3b5ff5c0707bee..e8be9e507fc678ed91f21b5e3914303783a5de48 100644 (file)
@@ -4,75 +4,8 @@ USING: inspector prettyprint ;
 USING: optimizer compiler-frontend compiler-backend inference ;
 IN: random-tester
 
-! Tweak me
-: max-length 5 ; inline
-: max-value 1000000000 ; inline
-
-
-! varying bit-length random number
-: random-bits ( n -- int )
-    random-int 2 swap ^ random-int ;
-
-: random-seq ( -- seq )
-    { [ ] { } V{ } "" } nth-rand
-    [ max-length random-int [ max-value random-int , ] times ] swap make ;
-
-SYMBOL: special-integers
-[ { -1 0 1 } % most-negative-fixnum , most-positive-fixnum , first-bignum , ] 
-{ } make \ special-integers set
-: special-integers ( -- seq ) \ special-integers get ;
-SYMBOL: special-floats
-[ { 0.0 } % e , pi , inf , -inf , 0/0. , epsilon , epsilon neg , ]
-{ } make \ special-floats set
-: special-floats ( -- seq ) \ special-floats get ;
-SYMBOL: special-complexes
-[ 
-    { -1 0 1 i -i } %
-    e , pi , 0 pi rect> , 0 pi neg rect> , pi neg 0 rect> , pi pi rect> ,
-    pi pi neg rect> , pi neg pi rect> , pi neg pi neg rect> ,
-    e neg e neg rect> , e e rect> ,
-] { } make \ special-complexes set
-
-: special-complexes ( -- seq ) \ special-complexes get ;
-
-: random-fixnum ( -- fixnum )
-    most-positive-fixnum random-int 1+ coin-flip [ neg 1- ] when >fixnum ;
-
-: random-bignum ( -- bignum )
-     400 random-bits first-bignum + coin-flip [ neg ] when ;
-    
-: random-integer
-    coin-flip [
-            random-fixnum
-        ] [
-            coin-flip [ random-bignum ] [ special-integers nth-rand ] if
-        ] if ;
-
-: random-positive-integer ( -- int )
-    random-integer dup 0 < [
-            neg
-        ] [
-            dup 0 = [ 1 + ] when
-    ] if ;
-
-: random-ratio ( -- ratio )
-    1000000000 dup [ random-int ] 2apply 1+ / coin-flip [ neg ] when dup [ drop random-ratio ] unless ;
-
-: random-float ( -- float )
-    coin-flip [ random-ratio ] [ special-floats nth-rand ] if
-    coin-flip 
-    [ .0000000000000000001 /f ] [ coin-flip [ .00000000000000001 * ] when ] if
-    >float ;
-
-: random-number ( -- number )
-    {
-        [ random-integer ]
-        [ random-ratio ]
-        [ random-float ]
-    } do-one ;
 
-: random-complex ( -- C{ } )
-    random-number random-number rect> ;
+
 
 
 ! Math vocabulary words
diff --git a/contrib/random-tester/random.factor b/contrib/random-tester/random.factor
new file mode 100644 (file)
index 0000000..52f35a5
--- /dev/null
@@ -0,0 +1,75 @@
+USING: kernel math sequences namespaces errors hashtables words arrays parser
+       compiler syntax lists io ;
+USING: inspector prettyprint ;
+USING: optimizer compiler-frontend compiler-backend inference ;
+IN: random-tester
+
+! Tweak me
+: max-length 5 ; inline
+: max-value 1000000000 ; inline
+
+! varying bit-length random number
+: random-bits ( n -- int )
+    random-int 2 swap ^ random-int ;
+
+: random-seq ( -- seq )
+    { [ ] { } V{ } "" } nth-rand
+    [ max-length random-int [ max-value random-int , ] times ] swap make ;
+
+SYMBOL: special-integers
+[ { -1 0 1 } % most-negative-fixnum , most-positive-fixnum , first-bignum , ] 
+{ } make \ special-integers set
+: special-integers ( -- seq ) \ special-integers get ;
+SYMBOL: special-floats
+[ { 0.0 } % e , pi , inf , -inf , 0/0. , epsilon , epsilon neg , ]
+{ } make \ special-floats set
+: special-floats ( -- seq ) \ special-floats get ;
+SYMBOL: special-complexes
+[ 
+    { -1 0 1 i -i } %
+    e , pi , 0 pi rect> , 0 pi neg rect> , pi neg 0 rect> , pi pi rect> ,
+    pi pi neg rect> , pi neg pi rect> , pi neg pi neg rect> ,
+    e neg e neg rect> , e e rect> ,
+] { } make \ special-complexes set
+
+: special-complexes ( -- seq ) \ special-complexes get ;
+
+: random-fixnum ( -- fixnum )
+    most-positive-fixnum random-int 1+ coin-flip [ neg 1- ] when >fixnum ;
+
+: random-bignum ( -- bignum )
+     400 random-bits first-bignum + coin-flip [ neg ] when ;
+    
+: random-integer
+    coin-flip [
+            random-fixnum
+        ] [
+            coin-flip [ random-bignum ] [ special-integers nth-rand ] if
+        ] if ;
+
+: random-positive-integer ( -- int )
+    random-integer dup 0 < [
+            neg
+        ] [
+            dup 0 = [ 1 + ] when
+    ] if ;
+
+: random-ratio ( -- ratio )
+    1000000000 dup [ random-int ] 2apply 1+ / coin-flip [ neg ] when dup [ drop random-ratio ] unless ;
+
+: random-float ( -- float )
+    coin-flip [ random-ratio ] [ special-floats nth-rand ] if
+    coin-flip 
+    [ .0000000000000000001 /f ] [ coin-flip [ .00000000000000001 * ] when ] if
+    >float ;
+
+: random-number ( -- number )
+    {
+        [ random-integer ]
+        [ random-ratio ]
+        [ random-float ]
+    } do-one ;
+
+: random-complex ( -- C{ } )
+    random-number random-number rect> ;
+