Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- user=> (let [f (future (reduce * (range 1 1001)))]
- (.get f 1 java.util.concurrent.TimeUnit/MILLISECONDS))
- java.util.concurrent.TimeoutException (NO_SOURCE_FILE:0)
- (defmacro time-limited [ms & body]
- `(let [f# (future ~@body)]
- (.get f# ~ms java.util.concurrent.TimeUnit/MILLISECONDS)))
- user=> (time-limited 1 (reduce * (range 1 1001)))
- java.util.concurrent.TimeoutException (NO_SOURCE_FILE:0)
- user=> (time-limited 1 (reduce * (range 1 101)))
- 93326215443944152681699238856266700490715968264381621468592963895217599993229915
- 608941463976156518286253697920827223758251185210916864000000000000000000000000
Add Comment
Please, Sign In to add comment