]> gitweb.factorcode.org Git - factor.git/commitdiff
random is generic now -- iota random -> random
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 14 Jan 2010 18:48:57 +0000 (12:48 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 14 Jan 2010 18:48:57 +0000 (12:48 -0600)
28 files changed:
basis/bit-arrays/bit-arrays-tests.factor
basis/calendar/calendar-tests.factor
basis/classes/struct/bit-accessors/bit-accessors-tests.factor
basis/compiler/tests/intrinsics.factor
basis/concurrency/combinators/combinators-tests.factor
basis/db/tester/tester.factor
basis/farkup/farkup-tests.factor
basis/io/files/unique/unique.factor
basis/math/intervals/intervals-tests.factor
basis/math/primes/primes.factor
basis/math/vectors/simd/simd-tests.factor
basis/persistent/hashtables/hashtables-tests.factor
basis/persistent/vectors/vectors-tests.factor
basis/random/mersenne-twister/mersenne-twister-tests.factor
basis/random/random-tests.factor
basis/random/random.factor
basis/serialize/serialize-tests.factor
basis/unrolled-lists/unrolled-lists-tests.factor
core/math/integers/integers-tests.factor
core/sorting/sorting-tests.factor
core/vectors/vectors-tests.factor
extra/24-game/24-game.factor
extra/benchmark/random/random.factor
extra/bloom-filters/bloom-filters-tests.factor
extra/decimals/decimals-tests.factor
extra/jamshred/oint/oint.factor
extra/jamshred/tunnel/tunnel.factor
extra/trees/splay/splay-tests.factor

index fbf0d4b639940e0c193681368cf1b99f31a71239..f08db68441c9484a7f17c2f3c9752abdf42719c2 100644 (file)
@@ -38,7 +38,7 @@ IN: bit-arrays.tests
 
 [ t ] [
     100 [
-        drop 100 [ 2 iota random zero? ] replicate
+        drop 100 [ 2 random zero? ] replicate
         dup >bit-array >array =
     ] all-integers?
 ] unit-test
index eb565a18d443ac781ec1643fafd91e2e0e71908d..2490b87c374b0876dc6bf991d2b7ec232f305a31 100644 (file)
@@ -175,4 +175,4 @@ IN: calendar.tests
 [ t ] [ 1325376000 unix-time>timestamp 2012 <year-gmt> = ] unit-test
 [ t ] [ 1356998399 unix-time>timestamp 2013 <year-gmt> 1 seconds time- = ] unit-test
 
-[ t ] [ 1500000000 iota random [ unix-time>timestamp timestamp>unix-time ] keep = ] unit-test
+[ t ] [ 1500000000 random [ unix-time>timestamp timestamp>unix-time ] keep = ] unit-test
index 037b316363b732428306795ca026b248bf92ef78..ecf7b68a2d89fc25a048998299451679511823b5 100644 (file)
@@ -4,5 +4,5 @@ USING: classes.struct.bit-accessors tools.test effects kernel
 sequences random stack-checker ;
 IN: classes.struct.bit-accessors.test
 
-[ t ] [ 20 iota random 20 iota random bit-reader infer (( alien -- n )) effect= ] unit-test
-[ t ] [ 20 iota random 20 iota random bit-writer infer (( n alien -- )) effect= ] unit-test
+[ t ] [ 20 random 20 random bit-reader infer (( alien -- n )) effect= ] unit-test
+[ t ] [ 20 random 20 random bit-writer infer (( n alien -- )) effect= ] unit-test
index 0ec84eb9915a72a304eaa484d43f960d816c1171..1c066f26a336c866e419ddf1bfdba4a6ba0a9d40 100644 (file)
@@ -337,7 +337,7 @@ ERROR: bug-in-fixnum* x y a b ;
 
 [ ] [
     10000 [
-        5 iota random iota [ drop 32 random-bits ] map product >bignum
+        5 random iota [ drop 32 random-bits ] map product >bignum
         dup [ bignum>fixnum ] keep compiled-bignum>fixnum =
         [ drop ] [ "Oops" throw ] if
     ] times
index 57a679f240dd6fa7840dcc6ad64b2ae3a7a2a221..f33f6513a97330472ef301dd3cac8601419f37bf 100644 (file)
@@ -11,7 +11,7 @@ IN: concurrency.combinators.tests
 \r
 [ { 1 4 9 } ] [ { 1 2 3 } [ sq ] parallel-map ] unit-test\r
 \r
-[ { 1 4 9 } ] [ { 1 2 3 } [ 1000000 iota random sleep sq ] parallel-map ] unit-test\r
+[ { 1 4 9 } ] [ { 1 2 3 } [ 1000000 random sleep sq ] parallel-map ] unit-test\r
 \r
 [ { 1 2 3 } [ dup 2 mod 0 = [ "Even" throw ] when ] parallel-map ]\r
 [ error>> "Even" = ] must-fail-with\r
index 1949ab42cc37f6e3178c9ec00f1bc18a20fa0795..d0ea6cbcf12eee933beefc083c1c12fa8664e67a 100644 (file)
@@ -57,7 +57,7 @@ test-2 "TEST2" {
 } define-persistent
 
 : test-1-tuple ( -- tuple )
-    f 100 iota random 100 iota random 100 iota random [ number>string ] tri@
+    f 100 random 100 random 100 random [ number>string ] tri@
     test-1 boa ;
 
 : db-tester ( test-db -- )
index e967250b230c848bd0007cfed79df861e875fc4c..7ef62bfb77eefcb955cbc304513d98c51db21dfc 100644 (file)
@@ -186,7 +186,7 @@ link-no-follow? off
 
 : random-markup ( -- string )
     10 [
-        2 iota random 1 = [
+        2 random 1 = [
             {
                 "[["
                 "*"
index 6a00ee523b91ae31619c17315ff51a3187cc3023..07f7b25140bdc192da95247e2ae6b589c81e75ae 100644 (file)
@@ -26,11 +26,11 @@ SYMBOL: unique-retries
 <PRIVATE
 
 : random-letter ( -- ch )
-    26 iota random { CHAR: a CHAR: A } random + ;
+    26 random { CHAR: a CHAR: A } random + ;
 
 : random-ch ( -- ch )
     { t f } random
-    [ 10 iota random CHAR: 0 + ] [ random-letter ] if ;
+    [ 10 random CHAR: 0 + ] [ random-letter ] if ;
 
 : random-name ( -- string )
     unique-length get [ random-ch ] "" replicate-as ;
index e38182bf9d896d671219158c3a21db9c3f77b5d8..3fa3e97cbabedb8d9f0e0bb9d187abae3fc7869e 100644 (file)
@@ -250,7 +250,7 @@ IN: math.intervals.tests
     dup full-interval eq? [
         drop 32 random-bits 31 2^ -
     ] [
-        [ ] [ from>> first ] [ to>> first ] tri over - iota random +
+        [ ] [ from>> first ] [ to>> first ] tri over - random +
         2dup swap interval-contains? [
             nip
         ] [
@@ -259,10 +259,10 @@ IN: math.intervals.tests
     ] if ;
 
 : random-interval ( -- interval )
-    10 iota random 0 = [ full-interval ] [
-        2000 iota random 1000 - dup 2 1000 iota random + +
-        1 iota random zero? [ [ neg ] bi@ swap ] when
-        4 iota random {
+    10 random 0 = [ full-interval ] [
+        2000 random 1000 - dup 2 1000 random + +
+        1 random zero? [ [ neg ] bi@ swap ] when
+        4 random {
             { 0 [ [a,b] ] }
             { 1 [ [a,b) ] }
             { 2 [ (a,b) ] }
@@ -366,7 +366,7 @@ comparison-ops [
 
 ! Test that commutative interval ops really are
 : random-interval-or-empty ( -- obj )
-    10 iota random 0 = [ empty-interval ] [ random-interval ] if ;
+    10 random 0 = [ empty-interval ] [ random-interval ] if ;
 
 : commutative-ops ( -- seq )
     {
index 19dcc6aeaf2dff7e89997e0d7d3a1a4c38e367de..81193af400bfa749003a2b01b831b5e9dfb059c3 100644 (file)
@@ -78,7 +78,7 @@ PRIVATE>
     >odd (find-relative-prime) ;
 
 : find-relative-prime ( n -- p )
-    dup iota random find-relative-prime* ;
+    dup random find-relative-prime* ;
 
 ERROR: too-few-primes n numbits ;
 
index d32ee5d443ed3650d581fcc33bba8f1a20fda471..342c565dcebe16590a4ac58b76835b3dd3616ef5 100644 (file)
@@ -151,7 +151,7 @@ CONSTANT: vector-words
 
 [ { } ] [
     with-ctors [
-        [ 1000 iota random '[ _ ] ] dip '[ _ execute ]
+        [ 1000 random '[ _ ] ] dip '[ _ execute ]
     ] [ = ] check-optimizer
 ] unit-test
 
@@ -165,7 +165,7 @@ CONSTANT: vector-words
 
 [ { } ] [
     boa-ctors [
-        [ stack-effect in>> length [ 1000 iota random ] [ ] replicate-as ] keep
+        [ stack-effect in>> length [ 1000 random ] [ ] replicate-as ] keep
         '[ _ execute ]
     ] [ = ] check-optimizer
 ] unit-test
@@ -175,12 +175,12 @@ CONSTANT: vector-words
 "== Checking vector operations" print
 
 : random-int-vector ( class -- vec )
-    new [ drop 1000 iota random ] map ;
+    new [ drop 1000 random ] map ;
 
 : random-float-vector ( class -- vec )
     new [
         drop
-        1000 iota random
+        1000 random
         10 swap <array> 0/0. suffix random
     ] map ;
 
@@ -193,7 +193,7 @@ CONSTANT: vector-words
     inputs [
         {
             { +vector+ [ class elt-class random-vector ] }
-            { +scalar+ [ 1000 iota random elt-class float = [ >float ] when ] }
+            { +scalar+ [ 1000 random elt-class float = [ >float ] when ] }
         } case
     ] [ ] map-as
     word '[ _ execute ] ;
@@ -255,13 +255,13 @@ simd-classes&reps [
 "== Checking boolean operations" print
 
 : random-boolean-vector ( class -- vec )
-    new [ drop 2 iota random zero? ] map ;
+    new [ drop 2 random zero? ] map ;
 
 :: check-boolean-op ( word inputs class elt-class -- inputs quot )
     inputs [
         {
             { +vector+ [ class random-boolean-vector ] }
-            { +scalar+ [ 1000 iota random elt-class float = [ >float ] when ] }
+            { +scalar+ [ 1000 random elt-class float = [ >float ] when ] }
         } case
     ] [ ] map-as
     word '[ _ execute ] ;
@@ -372,7 +372,7 @@ simd-classes&reps [
             [ [ 4 + ] map ] map
             [ append ] 2map
         ] }
-        [ dup '[ _ iota random ] replicate 1array ]
+        [ dup '[ _ random ] replicate 1array ]
     } case ;
 
 simd-classes [
@@ -387,7 +387,7 @@ simd-classes [
 "== Checking variable shuffles" print
 
 : random-shift-vector ( class -- vec )
-    new [ drop 16 iota random ] map ;
+    new [ drop 16 random ] map ;
 
 :: test-shift-vector ( class -- ? )
     [
index da2dd5f2c2208b79278e2ffcc87f0474b21d0970..482367ad9cf0277bd6c27e692de3346e3e9a0969 100644 (file)
@@ -81,7 +81,8 @@ M: hash-0-b hashcode* 2drop 0 ;
 ] unit-test
 
 : random-string ( -- str )
-    1000000 iota random ; ! [ CHAR: a CHAR: z [a,b] random ] "" replicate-as ;
+    1000000 random ;
+    ! [ CHAR: a CHAR: z [a,b] random ] "" replicate-as ;
 
 : random-assocs ( n -- hash phash )
     [ random-string ] replicate
index fe3365d32297432d5d001a866c112a78706d7ba1..6d340ca78a95b6575613c26caecdc81abfe7b84a 100644 (file)
@@ -27,7 +27,7 @@ vectors math math.order ;
 [ t ] [
     3000 iota [
         drop
-        16 random-bits 10000 iota random
+        16 random-bits 10000 random
         [ "1" [ new-nth ] change ]
         [ "2" [ new-nth ] change ] 2bi
         "1" get "2" get sequence=
@@ -62,10 +62,10 @@ vectors math math.order ;
 [ t ] [
     100 iota [
         drop
-        100 iota random [
+        100 random [
             16 random-bits [ "1" [ ppush ] change ] [ "2" get push ] bi
         ] times
-        100 iota random "1" get length min [
+        100 random "1" get length min [
             "1" [ ppop ] change
             "2" get pop*
         ] times
index 343baeebf4987be45bf614a94984bad26600e183..ede3c92f517b60cd2acf4f2c5b2d7e3442a3c244 100644 (file)
@@ -3,12 +3,12 @@ random.mersenne-twister sequences tools.test math.order ;
 IN: random.mersenne-twister.tests
 
 : check-random ( max -- ? )
-    [ iota random 0 ] keep between? ;
+    [ random 0 ] keep between? ;
 
 [ t ] [ 100 [ drop 674 check-random ] all-integers? ] unit-test
 
 : randoms ( -- seq )
-    100 [ 100 iota random ] replicate ;
+    100 [ 100 random ] replicate ;
 
 : test-rng ( seed quot -- )
     [ <mersenne-twister> ] dip with-random ; inline
index feebdb26e410fb8551a22d4d4941be96e25f01d6..9341b96b11499c604310cefd207658936882ce1e 100644 (file)
@@ -11,12 +11,12 @@ IN: random.tests
 [ 2 ] [ V{ 10 20 30 } [ delete-random drop ] keep length ] unit-test
 [ V{ } [ delete-random drop ] keep length ] must-fail
 
-[ t ] [ 10000 [ iota 0 [ drop 187 iota random + ] reduce ] keep / 2 * 187 10 ~ ] unit-test
-[ t ] [ 10000 [ iota 0 [ drop 400 iota random + ] reduce ] keep / 2 * 400 10 ~ ] unit-test
+[ t ] [ 10000 [ iota 0 [ drop 187 random + ] reduce ] keep / 2 * 187 10 ~ ] unit-test
+[ t ] [ 10000 [ iota 0 [ drop 400 random + ] reduce ] keep / 2 * 400 10 ~ ] unit-test
 
-[ t ] [ 1000 [ 400 iota random ] replicate prune length 256 > ] unit-test
+[ t ] [ 1000 [ 400 random ] replicate prune length 256 > ] unit-test
 
-[ f ] [ 0 iota random ] unit-test
+[ f ] [ 0 random ] unit-test
 
 [ { } ] [ { } randomize ] unit-test
 [ { 1 } ] [ { 1 } randomize ] unit-test
index 85e4e078c3927e72cfe159f5674775874b9089ae..1e54c567284315b8d0a9dd921c86d9ab921eb6e0 100644 (file)
@@ -52,7 +52,7 @@ PRIVATE>
 
 GENERIC: random ( obj -- elt )
 
-M: integer random random-integer ;
+M: integer random [ f ] [ random-integer ] if-zero ;
 
 M: sequence random
     [ f ] [
@@ -63,7 +63,7 @@ M: sequence random
 
 : randomize ( seq -- seq )
     dup length [ dup 1 > ]
-    [ [ iota random ] [ 1 - ] bi [ pick exchange ] keep ]
+    [ [ random ] [ 1 - ] bi [ pick exchange ] keep ]
     while drop ;
 
 ERROR: too-many-samples seq n ;
index 316eab6e5f51d0f8f2a0b7182982a7876b8d5098..036356e137975eeeec2fa147007450d2cacb2659 100644 (file)
@@ -9,7 +9,7 @@ SPECIALIZED-ARRAY: double
 IN: serialize.tests
 
 : test-serialize-cell ( a -- ? )
-    2^ iota random dup
+    2^ random dup
     binary [ serialize-cell ] with-byte-writer
     binary [ deserialize-cell ] with-byte-reader = ;
 
index 565f07037fec9fa2b3f641383f23aa217d274cf5..8eadfb9cbfebff667807a7980f124ea31858522a 100644 (file)
@@ -49,7 +49,7 @@ IN: unrolled-lists.tests
 
 [ t ] [
     <unrolled-list>
-    1000 [ 1000 iota random ] replicate
+    1000 [ 1000 random ] replicate
     [ [ over push-front ] each ]
     [ length [ dup pop-back ] replicate ]
     [ ]
@@ -60,7 +60,7 @@ IN: unrolled-lists.tests
 
 [ t ] [
     <unrolled-list>
-    1000 [ 1000 iota random ] replicate
+    1000 [ 1000 random ] replicate
     [
         10 group [
             [ [ over push-front ] each ]
index 768607ade8abd3665a8bec0c32f4106a026adaea..3f3ea7ba1bd0975df2192defafd6198556ffe5e5 100644 (file)
@@ -216,8 +216,8 @@ unit-test
 
 : random-integer ( -- n )
     32 random-bits
-    1 iota random zero? [ neg ] when
-    1 iota random zero? [ >bignum ] when ;
+    1 random zero? [ neg ] when
+    1 random zero? [ >bignum ] when ;
 
 [ t ] [
     1000 [
index 447dd1fb2b8f7c4cae6634299c211ba2244939dc..101cd75a5ba1f7aaf3a53bf49eba55ea584d754c 100644 (file)
@@ -11,7 +11,7 @@ unit-test
 [ t ] [
     100 [
         drop
-        100 [ 20 iota random [ 1000 iota random ] replicate ] replicate
+        100 [ 20 random [ 1000 random ] replicate ] replicate
         dup natural-sort
         [ set= ] [ nip [ before=? ] monotonic? ] 2bi and
     ] all-integers?
index 79248584e9a99a66807829f03e7ed8457a4f7fb9..8f644963bf0594cc33c12144eb3a20a19256dbbf 100644 (file)
@@ -26,7 +26,7 @@ IN: vectors.tests
 [ V{ 1 2 } ] [ [ 1 2 ] >vector ] unit-test
 
 [ t ] [
-    100 [ 100 iota random ] V{ } replicate-as
+    100 [ 100 random ] V{ } replicate-as
     dup >array >vector =
 ] unit-test
 
index a973cf3367d5e190b25e506a6f8e0c38244514b5..28600b6c48667452795f794d4138ee6d3892699b 100644 (file)
@@ -56,7 +56,7 @@ DEFER: check-status
         [ end-game ] 
         [ dup quit? [ quit-game ] [ repeat ] if ]
     if ;
-: build-quad ( -- array ) 4 [ 10 iota random ] replicate ;
+: build-quad ( -- array ) 4 [ 10 random ] replicate ;
 : 24-able? ( quad -- t/f ) [ makes-24? ] with-datastack first ;
 : 24-able ( -- vector ) build-quad dup 24-able? [ drop build-quad ] unless ;
 : set-commands ( -- ) { + - * / rot swap q } commands set ;
index 761bf8478f65682adb6d9dfd1c6cf495a266a681..b5abc4f68736473cd9fb03abb02ea1617c489567 100644 (file)
@@ -7,7 +7,7 @@ IN: benchmark.random
 
 : write-random-numbers ( n -- )
     random-numbers-path ascii [
-        [ 200 iota random 100 - number>string print ] times
+        [ 200 random 100 - number>string print ] times
     ] with-file-writer ;
 
 : random-main ( -- )
index 14c6b4145338cde2f3288818caf17eec54a85f7f..f4055ca9e06c74813889e190fd003a3996ef831f 100644 (file)
@@ -70,7 +70,7 @@ IN: bloom-filters.tests
 ] unit-test
 
 ! We shouldn't have more than 0.01 false-positive rate.
-[ t ] [ 1000 iota [ drop most-positive-fixnum iota random 1000 + ] map
+[ t ] [ 1000 iota [ drop most-positive-fixnum random 1000 + ] map
         full-bloom-filter
         [ bloom-filter-member? ] curry map
         [ ] count
index 34ad094bc8e074b67c56154d1696fa8502b7b218..5bd0fb0fa3a3868a63045970540aa95873f2132a 100644 (file)
@@ -10,7 +10,7 @@ IN: decimals.tests
 ] unit-test
 
 : random-test-int ( -- n )
-    10 iota random 2 iota random 0 = [ neg ] when ;
+    10 random 2 random 0 = [ neg ] when ;
 
 : random-test-decimal ( -- decimal )
     random-test-int random-test-int <decimal> ;
index 265a1d6c6ab7ce3f302730838c04d9fb576aaa18..1b1d87fbab4f0ac093419c93cd9bd0e6f3cb8f90 100644 (file)
@@ -34,7 +34,7 @@ C: <oint> oint
 
 : random-float+- ( n -- m )
     #! find a random float between -n/2 and n/2
-    dup 10000 * >integer iota random 10000 / swap 2 / - ;
+    dup 10000 * >integer random 10000 / swap 2 / - ;
 
 : random-turn ( oint theta -- )
     2 / 2dup random-float+- left-pivot random-float+- up-pivot ;
index 5dc88936beb5efc9b5590b071bb35b32b6d2a44e..f94fc979ce630961f78d8272d383763473d777f2 100644 (file)
@@ -21,7 +21,7 @@ C: <segment> segment
     0 swap length clamp ;
 
 : random-color ( -- color )
-    { 100 100 100 } [ iota random 100 / >float ] map first3 1.0 <rgba> ;
+    { 100 100 100 } [ random 100 / >float ] map first3 1.0 <rgba> ;
 
 CONSTANT: tunnel-segment-distance 0.4
 CONSTANT: random-rotation-angle $[ pi 20 / ]
index d880d51390ed8592c589b37ea20a106526985a6b..d858a14795d9c38d4df347ea24cd524c7c54129f 100644 (file)
@@ -5,7 +5,7 @@ sequences random sets make grouping ;
 IN: trees.splay.tests
 
 : randomize-numeric-splay-tree ( splay-tree -- )
-    100 iota [ drop 100 iota random swap at drop ] with each ;
+    100 iota [ drop 100 random swap at drop ] with each ;
 
 : make-numeric-splay-tree ( n -- splay-tree )
     iota <splay> [ [ conjoin ] curry each ] keep ;