Lazier than lazy

utilities — cgrand, 23 June 2008 @ 20 h 47 min

If you can’t put off what you have to do, ask someone else to do it for you.

(defn off
 "Computes a lazy-seq in another (dedicated) thread."
 [s]
  (let [ex (. java.util.concurrent.Executors newSingleThreadExecutor)]
    ((fn this [s]
       (if s 
         (let [future-rest (java.util.concurrent.FutureTask. #(rest s))]
           (.execute ex future-rest)
             (lazy-cons (first s) (this (.get future-rest))))
         (.shutdown ex))) s)))

14 Comments »

  1. a similar case as the Daechi-dong incident

    Comment by Optimum — 15 April 2023 @ 2 h 51 min
  2. The Korea Herald is running a series of

    Comment by Optimum — 15 April 2023 @ 2 h 52 min
  3. evolution and rise of drug crimes

    Comment by Optimum — 15 April 2023 @ 2 h 53 min
  4. Free drinks were offered last week

    Comment by Optimum — 15 April 2023 @ 2 h 53 min
  5. on the streets of Daechi-dong

    Comment by Optimum — 15 April 2023 @ 2 h 54 min
  6. a district in Seoul’s Gangnam lined with

    Comment by Optimum — 15 April 2023 @ 2 h 57 min
  7. thousands of after-school cram

    Comment by Optimum — 15 April 2023 @ 2 h 58 min
  8. schools and known as South

    Comment by Optimum — 15 April 2023 @ 2 h 58 min
  9. Korea’s private education mecca

    Comment by Optimum — 15 April 2023 @ 2 h 59 min
  10. In exchange for the free drinks, the

    Comment by Optimum — 15 April 2023 @ 2 h 59 min
  11. people handing them out allegedly asked high

    Comment by Optimum — 15 April 2023 @ 3 h 00 min
  12. schoolers for their parents’ contact information

    Comment by Optimum — 15 April 2023 @ 3 h 00 min
  13. according to the police. These

    Comment by Optimum — 15 April 2023 @ 3 h 00 min
  14. people later demanded some 100

    Comment by Optimum — 15 April 2023 @ 3 h 01 min

RSS feed for comments on this post. TrackBack URI

Leave a comment

(c) 2024 Clojure and me | powered by WordPress with Barecity