RosettaCodeData/Task/Constrained-random-points-on-a-circle/Hy/constrained-random-points-on-a-circle.hy
2023-07-01 13:44:08 -04:00

17 lines
424 B
Hy

(import
math [sqrt]
random [choice]
matplotlib.pyplot :as plt)
(setv possible-points
(lfor
x (range -15 16)
y (range -15 16)
:if (<= 10 (sqrt (+ (** x 2) (** y 2))) 15)
[x y]))
(setv [xs ys] (zip #* (map (fn [_] (choice possible-points)) (range 100))))
; We can't use random.sample because that samples without replacement.
; #* is also known as unpack-iterable
(plt.plot xs ys "bo")
(plt.show)