- 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 1 (169.88 KiB) Viewed 6 times
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
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 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 ac
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