May 2019
Beginner to intermediate
466 pages
10h 44m
English
Let's start by editing Letters.jl to make it look like this:
module Letters
using Random
export randstring
const MY_NAME = "Letters"
function rand()
Random.rand('A':'Z')
end
function randstring()
[rand() for _ in 1:10] |> join
end
include("module_name.jl")
end
Here, we have defined a module called Letters. In it, we added a rand function that uses Julia's Random.rand to return a random letter between A and Z in the form of a Char. Next, we added a function called Letters.randstring, which returns a String of 10 random characters. This string is generated using a Char[] array comprehension (the _ variable name is perfectly legal in Julia and, by convention, it designates a variable whose value is not used) which is ...
Read now
Unlock full access