Skip to content

Commit

Permalink
add rand([rng], ::String, [chars], n=8)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Jun 5, 2017
1 parent 0d91a23 commit cdb89ac
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion base/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1416,18 +1416,34 @@ let b = UInt8['0':'9';'A':'Z';'a':'z']
randstring(r::AbstractRNG, n::Int) = randstring(r, b, n)
randstring(chars::AbstractArray{<:Union{UInt8,Char}}=b, n::Int=8) = randstring(GLOBAL_RNG, chars, n)
randstring(n::Int) = randstring(GLOBAL_RNG, b, n)

rand(rng::AbstractRNG, ::Type{String}, chars::AbstractArray{<:Union{UInt8,Char}}=b, n::Int=8) =
randstring(rng, chars, n)
rand(rng::AbstractRNG, ::Type{String}, n::Int) = randstring(rng, b, n)
rand(::Type{String}, chars::AbstractArray{<:Union{UInt8,Char}}=b, n::Int=8) =
randstring(GLOBAL_RNG, chars, n)
rand(::Type{String}, n::Int) = randstring(GLOBAL_RNG, b, n)
end

"""
randstring([rng=GLOBAL_RNG], [chars::AbstractArray{<:Union{UInt8,Char}}], [len=8])
Create a random ASCII string of length `len`, consisting of characters
Create a random string of length `len`, consisting of characters
from `chars` if specified, and of upper- and lower-case letters and
the digits 0-9 otherwise. The optional `rng` argument specifies a
random number generator, see [Random Numbers](@ref).
"""
randstring

"""
rand([rng=GLOBAL_RNG], ::Type{String}, [chars::AbstractArray{<:Union{UInt8,Char}}], [len=8])
Create a random string of length `len`, consisting of characters
from `chars` if specified, and of upper- and lower-case letters and
the digits 0-9 otherwise. Equivalent to [`randstring`](@ref)`(rng, chars, len)`.
"""
rand

# Fill S (resized as needed) with a random subsequence of A, where
# each element of A is included in S with independent probability p.
# (Note that this is different from the problem of finding a random
Expand Down

0 comments on commit cdb89ac

Please sign in to comment.