Clojure (2) hash map and check-login function

Is there HashMap in clojure
Yes It it.

below is hash map and check-login function
(def users 
  {"kyle" {:password "secretk" :number-pets 2}
   "siva" {:password "secrets" :number-pets 4}
   "rob" {:password "secretr" :number-pets 6}
   "george" {:password "secretg" :number-pets 8}})

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


try to use check-login function
hello.core=> (check-login "kyle" "secretks")
false

hello.core=> (check-login "kyle" "secretk")
true

Comments

Popular posts from this blog

Project euler 169 found clue

Floyd-Warshall's algorithm