Skip to content

Instantly share code, notes, and snippets.

@andrewhr
Created May 21, 2015 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewhr/82b77b80365be686ff83 to your computer and use it in GitHub Desktop.
Save andrewhr/82b77b80365be686ff83 to your computer and use it in GitHub Desktop.
#protip this is not the Clojure you're looking for...
(deftype Event (U :new-release))
(defn probability :- Float
"Return the probability of some `Event` to occur. IRL this should be some
real and complicated calculus instead of a simply constant"
[event :- Event :> Float]
0.95)
(defn descriptive-propability
"Describe the probability of a given `Event` to occur, for human readers."
[event :- Event] :- String
(match (probability event)
1.00 "certain"
0.00 "impossible"
(range 0.00 0.25) "very unlikely"
(range 0.25 0.50) "unlikely"
(range 0.50 0.75) "likely"
(range 0.75 1.00) "very likely"
_ (unreachable!)))
(defn -main []
(println! (descriptive-propability :new-release)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment