Constrained random points on a circle: Difference between revisions
Content added Content deleted
Line 404: | Line 404: | ||
* ** |
* ** |
||
</pre> |
</pre> |
||
=={{header|Clojure}}== |
|||
<lang Clojure>(import '[java.awt Color Graphics Dimension] |
|||
'[javax.swing JFrame JPanel]) |
|||
(let [points (->> (for [x (range -15 16) |
|||
y (range -15 16) |
|||
:when (<= 10 (Math/sqrt (+ (* x x) (* y y))) 15)] |
|||
[(+ x 15) (+ y 15)]) |
|||
shuffle |
|||
(take 100 ,))] |
|||
(doto (JFrame.) |
|||
(.add (doto (proxy [JPanel] [] |
|||
(paint [^Graphics g] |
|||
(doseq [[x y] points] |
|||
(.fillRect g (* 10 x) (* 10 y) 10 10)))) |
|||
(.setPreferredSize (Dimension. 310 310)))) |
|||
(.setResizable false) |
|||
(.setDefaultCloseOperation JFrame/DISPOSE_ON_CLOSE) |
|||
.pack |
|||
.show))</lang> |
|||
=={{header|D}}== |
=={{header|D}}== |
||
Line 460: | Line 481: | ||
1 1 |
1 1 |
||
1 </pre> |
1 </pre> |
||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |
||
This version uses method 1 from the task description and just calculates 100 suitable points to plot. |
This version uses method 1 from the task description and just calculates 100 suitable points to plot. |