Given the following code snippet to transfer the funds from account1 to account2. 3. 4 5. 6. 7 8. 9. 10. 11. 12. (def ac
Posted: Tue Jul 05, 2022 10:25 am
Given the following code snippet to transfer the funds from account1 to account2. 3. 4 5. 6. 7 8. 9. 10. 11. 12. (def accountl (atom 0 :validator #(>= 0))) (def account2 (atom 0:validator #(>= 8 0))) (defn transfer [from-acct to-acct amt] (swap! to-acct+amt) (swap! from-acct amt)) (future (transfer account1 account2 100)) (println (str "accountl: "@account1)) (println (str "account2: "@account2)) Determine the output of the given code and justify your answer. 5 Marks Use Ref Clojure function instead of the atom in the given code and justify the reason of why Ref is more effective than the atom. 13 Marks