RosettaCodeData/Task/Evolutionary-algorithm/Elixir/evolutionary-algorithm-1.el...

16 lines
385 B
Plaintext

defmodule Rand do
def init do # Initialize the random values.
<< a :: 32, b :: 32, c :: 32 >> = :crypto.strong_rand_bytes(12)
:random.seed(a,b,c)
end
def num do # Returns a value between 0.0 and 1.0.
init
:random.uniform
end
def char(list) do # Returns a random letter or a space.
Enum.at(list, :random.uniform(length(list)) - 1)
end
end