Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LIST PROGRAMMING PROBLEM Problem #1 Define a function that takes two arguments and returns the greater of the two. Problem #2 Write a function called

LIST PROGRAMMING PROBLEM Problem #1 Define a function that takes two arguments and returns the greater of the two. Problem #2 Write a function called inches that accepts feet and inches and returns the equivalent length in centimeters. If x is the first argument and y is the second, the formula is 2.54(12x + y). For example, USER(1): (inches 0 1) 2.54 USER(1): (inches 6 2.5) 189.22999999999999 Problem #3 - Remove an element from a list using Iteration Write a Common Lisp function called my-remove that takes an atom and a list in input, and returns a list that is identical to the input list, but with elements equal to the input atom removed, if any. Examples of the function in operation are shown below (user input is in red): CL-USER(1): (my-remove 'b '(a b c b d)) (a c d) CL-USER(2): (my-remove 'b '(a c d e f)) (a c d e f) CL-USER(3): (my-remove 'a '(b (a d) a d)) (b (a d) d) CL-USER(4): (my-remove 'a '()) nil Problem #4 - Remove an element from a list using Recursion Write a Common Lisp function called my-recursive-remove that takes an atom and a list in input, and returns a list that is identical to the input list, but with all occurrences of the input atom removed, if any. Examples of the function in operation are shown below (user input is in red): CL-USER(1): (my-recursive-remove 'a '(a b c d)) (b c d) CL-USER(2): (my-recursive-remove 'a '((a b) a (c d e a) (a a) b)) ((b) (c d e) nil b)) CL-USER(3): (my-recursive-remove 'a '((((a))))) (((nil))) Problem #5 - Flatten a list Write a Common Lisp function called flatten that takes a list that may have embedded lists, and returns a flattened version of it (i.e., a list whose elements are only atoms and empty lists have been removed). Examples of the function in operation (user input is in red): CL-USER(1): (flatten '(a b c d)) (a b c d) CL-USER(2): (flatten '(a () b (c d))) (a b c d) CL-USER(3): (flatten '(a (()))) (a) CL-USER(4): (flatten '(a (b c) (d e (f) ((((((g)))) h)) i) j (k) l)) (a b c d e f g h i j k l)

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions

Question

What is polarization? Describe it with examples.

Answered: 1 week ago