Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn Mysql The Easy Way A Beginner Friendly Guide

Authors: Kiet Huynh

1st Edition

B0CNY7143T, 979-8869761545

More Books

Students also viewed these Databases questions

Question

1. Discuss the four components of language.

Answered: 1 week ago

Question

a. How many different groups were represented?

Answered: 1 week ago