Merge branch 'master' of git://factorcode.org/git/factor
commit
f0f53d2e04
basis
tools/deploy
|
@ -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:"
|
||||
|
|
|
@ -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 ;
|
||||
|
||||
|
|
|
@ -321,7 +321,7 @@ IN: tools.deploy.shaker
|
|||
] [ drop ] if ;
|
||||
|
||||
: strip-c-io ( -- )
|
||||
deploy-io get 2 = [
|
||||
deploy-io get 2 = os windows? or [
|
||||
[
|
||||
c-io-backend forget
|
||||
"io.streams.c" forget-vocab
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
USING: tools.deploy.config ;
|
||||
H{
|
||||
{ deploy-threads? f }
|
||||
{ deploy-ui? f }
|
||||
{ deploy-io 1 }
|
||||
{ deploy-c-types? f }
|
||||
{ deploy-name "tools.deploy.test.6" }
|
||||
{ deploy-compiler? t }
|
||||
{ deploy-reflection 1 }
|
||||
{ deploy-word-props? f }
|
||||
{ deploy-io 1 }
|
||||
{ deploy-name "tools.deploy.test.6" }
|
||||
{ deploy-math? t }
|
||||
{ deploy-random? f }
|
||||
{ deploy-compiler? t }
|
||||
{ deploy-ui? f }
|
||||
{ deploy-c-types? f }
|
||||
{ deploy-word-defs? f }
|
||||
{ "stop-after-last-window?" t }
|
||||
{ deploy-random? f }
|
||||
{ deploy-math? f }
|
||||
{ deploy-threads? f }
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ IN: tools.deploy.windows
|
|||
"resource:freetype6.dll"
|
||||
"resource:zlib1.dll"
|
||||
} swap copy-files-into
|
||||
] when ;
|
||||
] [ drop ] if ;
|
||||
|
||||
: create-exe-dir ( vocab bundle-name -- vm )
|
||||
deploy-ui? get [
|
||||
|
|
Loading…
Reference in New Issue