Skip to content

Instantly share code, notes, and snippets.

@dustingetz
Last active January 14, 2020 21:42
Show Gist options
  • Select an option

  • Save dustingetz/cf220d0a3a26abd1cb9b099dbe18f0cf to your computer and use it in GitHub Desktop.

Select an option

Save dustingetz/cf220d0a3a26abd1cb9b099dbe18f0cf to your computer and use it in GitHub Desktop.
(defn foo! [i]
  (rand-nth (concat
              (range 20)
              [{:cognitect.anomalies/anomaly {:cognitect.anomalies/category :cognitect.anomalies/unavailable}}
               {:cognitect.anomalies/anomaly {:cognitect.anomalies/category :cognitect.anomalies/busy}}
               {:cognitect.anomalies/anomaly {:cognitect.anomalies/category :cognitect.anomalies/forbidden}}])))

(map foo! (range 15))
(18
 12
 8
 13
 1
 14
 13
 #:cognitect.anomalies{:anomaly #:cognitect.anomalies{:category :cognitect.anomalies/unavailable}}
 8
 15
 2
 2
 13
 6
 14)

Do we really want to throw away the rest of the computation? That probably depends what you're doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment