Question
Please answer the following questions in scheme programming language 1.replaceallwith takes an atom and two lists of atoms. Each occurrence if the atom in the
Please answer the following questions in scheme programming language
1.replaceallwith takes an atom and two lists of atoms. Each occurrence if the atom in the first list is replaced by one of the atoms of the second list, in order. So, the first occurrence of the atom in the first list is replaced by the first atom of the second list, the second occurrence is replaced by the second atom of the second list, and so on. If there are not enough atoms in the second list, the rest of the first list is unchanged.
> (replacewith 'x '(a b x c d x e x x f x) '(1 2 3 4)) '(a b 1 c d 2 e 3 4 f x)
2.everyother* takes a list that may contain sublists. The function returns a list that contains every other element of the input list, and if the element is also a list, then every other element of that sublist is included in the returned list, and so on for each sublists it contains.
> (everyother* '(a (b c (d)) ((e f g) h (((i)) () (j k)) (l m n)))) '(a ((e g) (((i)) (j))))
3.
myequal takes two lists that may contain sublists and returns #t if they have exactly the same atoms and sublists in the same order.
> (myequal '(a b (c ((d) e f) g)) '(a b (c ((d) e f) g))) #t > (myequal '(a b (c ((d) e f) g)) '(a b (c ((e) e f) g))) #f > (myequal '(a b (c ((d) e f) g)) '(a b (c (d e f) g))) #f
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started