Guest User

Untitled

a guest
Sep 19th, 2010
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. (defn r-squared [x y]
  2. (+ (* (- 0.5 x) (- 0.5 x))
  3. (* (- 0.5 y) (- 0.5 y))))
  4.  
  5. (loop [hits 0]
  6. (let [x (rand)
  7. y (rand)]
  8. ; still inside the let
  9. (if (< (r-squared x y) 0.25)
  10. (recur (inc hits)) ; then expression, restarts the loop
  11. (* 4 (/ hits throws))))) ; else-expression, the return value of the loop
Add Comment
Please, Sign In to add comment