Advertisement
CodeTortoise

Vampire ID

Jan 25th, 2016
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (def vampire-database
  2.   {0 {:makes-blood-puns? false :has-pulse? true  :name "McFishwich"}
  3.    1 {:makes-blood-puns? false :has-pulse? true  :name "McWackson"}
  4.    2 {:makes-blood-puns? true  :has-pulse? false :name "Damon Salvatore"}
  5.    3 {:makes-blood-puns? true  :has-pulse? true  :name "Mickey Mouse"}})
  6.  
  7. (defn vampire-related-details
  8.   [social-security-number]
  9.   (Thread/sleep 1000)
  10.   (get vampire-database social-security-number))
  11.  
  12. (defn vampire?
  13.   [record]
  14.   (and (:makes-blood-puns? record)
  15.        (not (:has-pulse record))
  16.        (record)))
  17.  
  18. (defn identify-vampire
  19.   [social-security-numbers]
  20.   (first (filter vampire?
  21.                  (map vampire-related-details social-security-numbers))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement