Guest User

Untitled

a guest
Apr 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. user=> (let [f (future (reduce * (range 1 1001)))]
  2. (.get f 1 java.util.concurrent.TimeUnit/MILLISECONDS))
  3. java.util.concurrent.TimeoutException (NO_SOURCE_FILE:0)
  4.  
  5. (defmacro time-limited [ms & body]
  6. `(let [f# (future ~@body)]
  7. (.get f# ~ms java.util.concurrent.TimeUnit/MILLISECONDS)))
  8.  
  9. user=> (time-limited 1 (reduce * (range 1 1001)))
  10. java.util.concurrent.TimeoutException (NO_SOURCE_FILE:0)
  11. user=> (time-limited 1 (reduce * (range 1 101)))
  12. 93326215443944152681699238856266700490715968264381621468592963895217599993229915
  13. 608941463976156518286253697920827223758251185210916864000000000000000000000000
Add Comment
Please, Sign In to add comment