Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -0,0 +1,30 @@
|
|||
defmodule Random do
|
||||
def init() do
|
||||
:random.seed(:erlang.now())
|
||||
end
|
||||
def generate_point() do
|
||||
x = :random.uniform(31) - 16
|
||||
y = :random.uniform(31) - 16
|
||||
if 10*10 <= x*x + y*y and x*x + y*y <= 15*15 do
|
||||
{x, y}
|
||||
else
|
||||
generate_point()
|
||||
end
|
||||
end
|
||||
def circle() do
|
||||
points = for _ <- 1..100, do: generate_point()
|
||||
for x <- -15..15 do
|
||||
for y <- -15..15 do
|
||||
if Enum.member?(points, {x, y}) do
|
||||
IO.write "x"
|
||||
else
|
||||
IO.write " "
|
||||
end
|
||||
end
|
||||
IO.puts ""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Random.init()
|
||||
Random.circle()
|
||||
Loading…
Add table
Add a link
Reference in a new issue