Question: I need to use clojure. 1.Define a function (account-name id owner) that takes integer (id) and string (owner) as arguments. The function must return a
I need to use clojure. 1.Define a function (account-name id owner) that takes integer (id) and string (owner) as arguments. The function must return a map with key :owner set to the owner argument, key :id set to the id argument and key :balance set to 0 (zero). Examples: > (account-name 10 "Jo") {:owner "Jo", :id 10, :balance 0} > (account-name 99 "Jim") {:owner "Jim", :id 99, :balance 0} 2.Define a function (deposit account amount) that accepts a map, account, and a number, amount, as arguments. The map account will map the keyword :balance to a number. Your function deposit must return a new map with the :balance value increased by amount, if amount is positive or unchanged (if amount is not positive). > (deposit {:owner "Jo", :id 12983, :balance 1000} 150) {:owner "Jo", :id 12983, :balance 1150} > (deposit {:owner "Jim", :id 7187, :balance 3000} 89) {:owner "Jim", :id 7187, :balance 3089} > (deposit {:owner "Becky", :id 111, :balance 2000} -3) {:owner "Becky", :id 111, :balance 2000} > (deposit {:balance 33} 5) {:balance 38}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
