Consider the really slow fib function: (defn fib [n] (if (< n 2) n (+ (fib (dec n)) (fib (- n 2)))))
Now, let's say I want to compute the fib of some number n and timeout and return nil if it takes longer than a second. (defn try-fib [n] (let [ch (timeout 1000)] (go (>! ch (fib n))) (<!! ch))) This works, but let's say I invoke (try-fib 60). After one second, it returns nil, but my CPU is still churning trying to compute (fib 60). Is there some way to alter try-fib so that after returning nil, it cancels the thread that is computing the intensive, never-ending computation? -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.