Skip to content

Commit

Permalink
Apply, map over users, basic division
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnaxsom committed Apr 2, 2017
1 parent 1672706 commit da4fbbf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test2.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(def users {
"frank" { :age 22 :gender "male" :password "frankspassword" :number-of-pets 1}
"suzy" { :age 45 :gender "female" :password "suzyspassword" :number-of-pets 3 }})


(defn check-login [username password]
(let [actual-password ((users username) :password)]
(= password actual-password)))

(println (check-login "frank" "frankspassword"))
(println (check-login "frank" "wrongpassword"))

(defn average-pets []
(/
(apply + (map :number-of-pets (vals users)))
(count users)))

(println (average-pets))

0 comments on commit da4fbbf

Please sign in to comment.