Question: Do not use any of the built-in Clojure functions/macros except: def, defn, fn, if, cond, let, arithmetic operations, comparison operations, and, or, not, str, seq,

Do not use any of the built-in Clojure functions/macros except: def, defn, fn, if, cond, let, arithmetic operations, comparison operations, and, or, not, str, seq, cons, first, rest, nth, zero?, seq?, empty?, nil?, odd?, even?, assoc. Create the following functions using Clojure. 1. (swapper s1 s2 slist) returns a list the same as slist, but with all occurrences of s1 replaced by s2 and all occurrences of s2 replaced by s1. > (swapper a d (a b c d)) (d b c a)

2. (list-set lst n x) returns a list like lst, except that the n-th element, using zero-based indexing, is x. n will always satisfy (and (>= n 0)(< (count lst))) (that is, it will be a valid existing index). > (list-set (a b c d) 2 (1 2)) (a b (1 2) d)

3. (count-occurrences s lst) returns the number of occurrences of s in lst. > (count-occurrences x ((f x) y (((x z) x)))) 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!