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
 
No comments:
Post a Comment